Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrokeil committed Feb 14, 2017
2 parents 74fc934 + d8e9fe8 commit 195e553
Show file tree
Hide file tree
Showing 58 changed files with 2,429 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .docheader
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
* Sandro Keil (https://sandro-keil.de)
*
* @link http://github.com/sandrokeil/interop-config for the canonical source repository
* @copyright Copyright (c) 2015-2016 Sandro Keil
* @copyright Copyright (c) 20%regexp:\d{2}%-%year% Sandro Keil
* @license http://github.com/sandrokeil/interop-config/blob/master/LICENSE.md New BSD License
*/
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ matrix:
- EXECUTE_TEST_COVERALLS=true
- EXECUTE_CS_CHECK=true
- EXECUTE_DOCHEADER_CHECK=true
- php: hhvm
allow_failures:
- php: hhvm

Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.1.0 (2017-02-14)

### Added

* [#36](https://github.com/sandrokeil/interop-config/issues/36): Create console tools to generate/display config based on factories. Read more in the [docs](https://sandrokeil.github.io/interop-config/reference/console-tools.html).
* Composer suggestion of `psr/container`

### Deprecated

* Nothing

### Removed

* Composer suggestion of `container-interop/container-interop`

### Fixed

* Nothing


## 2.0.1 (2016-12-09)
This release contains **no** BC break.

Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Documentation is [in the doc tree](doc/), and can be compiled using [bookdown](h

```console
$ docker run -it --rm -v $(pwd):/app sandrokeil/bookdown doc/bookdown.json
$ docker run -it --rm -p 8080:8080 -v $(pwd):/app php:7.0-cli php -S 0.0.0.0:8080 -t /app/doc/html
$ docker run -it --rm -p 8080:8080 -v $(pwd):/app php:7.1-cli php -S 0.0.0.0:8080 -t /app/doc/html
```

or run *bookdown*
Expand All @@ -64,18 +64,12 @@ $ php -S 0.0.0.0:8080 -t doc/html/
Then browse to [http://localhost:8080/](http://localhost:8080/)

## Projects
This is a list of projects who are using `interop-config` interfaces (incomplete).
This is a list of projects who are using `interop-config` interfaces ([incomplete](https://packagist.org/packages/sandrokeil/interop-config/dependents)).

* [prooph/service-bus](https://github.com/prooph/service-bus) - PHP Lightweight Message Bus supporting CQRS
* [prooph/event-store](https://github.com/prooph/event-store) - PHP EventStore Implementation
* [prooph/event-store-doctrine-adapter](https://github.com/prooph/event-store-doctrine-adapter) - Doctrine Adapter for ProophEventStore
* [prooph/event-store-mongodb-adapter](https://github.com/prooph/event-store-mongodb-adapter) - MongoDB Adapter for ProophEventStore
* [prooph/snapshotter](https://github.com/prooph/snapshotter) - snapshot tool for prooph event-store
* [prooph/snapshot-memcached-adapter](https://github.com/prooph/snapshot-memcached-adapter) - Snapshot Memcached Adapter for ProophEventStore
* [prooph/snapshot-doctrine-adapter](https://github.com/prooph/snapshot-doctrine-adapter) - Snapshot Doctrine Adapter for ProophEventStore
* [prooph/laravel-package](https://github.com/prooph/laravel-package) - Laravel package for prooph components
* [prooph/service-bus-symfony-bundle](https://github.com/prooph/service-bus-symfony-bundle) - Symfony Bundle for prooph service bus
* [prooph/event-store-symfony-bundle](https://github.com/prooph/event-store-symfony-bundle) - Symfony Bundle for prooph event store
* [prooph/snapshot-store](https://github.com/prooph/snapshot-store) - Simple and lightweight snapshot store
* [prooph/psr7-middleware](https://github.com/prooph/psr7-middleware) - PSR-7 Middleware for prooph components

## Benchmarks
The benchmarks uses [PHPBench](http://phpbench.readthedocs.org/en/latest/) and can be started by the following command:
Expand Down
3 changes: 3 additions & 0 deletions bin/interop-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env php
<?php
require 'interop-config.php';
68 changes: 68 additions & 0 deletions bin/interop-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Sandro Keil (https://sandro-keil.de)
*
* @link http://github.com/sandrokeil/interop-config for the canonical source repository
* @copyright Copyright (c) 2017 Sandro Keil
* @license http://github.com/sandrokeil/interop-config/blob/master/LICENSE.md New BSD License
*/

namespace Interop\Config;

// Setup/verify autoloading
use Interop\Config\Tool\ConsoleHelper;

if (file_exists($a = getcwd() . '/vendor/autoload.php')) {
require $a;
} elseif (file_exists($a = __DIR__ . '/../../../autoload.php')) {
require $a;
} elseif (file_exists($a = __DIR__ . '/../vendor/autoload.php')) {
require $a;
} else {
fwrite(STDERR, 'Cannot locate autoloader; please run "composer install"' . PHP_EOL);
exit(1);
}

$argv = array_slice($argv, 1);

$command = array_shift($argv);

$help = <<<EOF
<info>Usage:</info>
command [options] [arguments]
<info>Options:</info>
<value>-h, --help, help</value> Display this help message
<info>Available commands:</info>
<value>generate-config</value> Generates options for the provided class name
<value>display-config</value> Displays current options for the provided class name
EOF;

try {
switch ($command) {
case 'display-config':
$command = new Tool\ConfigReaderCommand();
$status = $command($argv);
exit($status);
case 'generate-config':
$command = new Tool\ConfigDumperCommand();
$status = $command($argv);
exit($status);
case '-h':
case '--help':
case 'help':
$consoleHelper = new ConsoleHelper();
$consoleHelper->writeLine($help);
exit(0);
default:
$consoleHelper = new ConsoleHelper();
$consoleHelper->writeErrorMessage(strip_tags($help));
exit(1);
}
} catch (\Throwable $e) {
$consoleHelper = new ConsoleHelper();
$consoleHelper->writeErrorMessage($e->getMessage());
$consoleHelper->writeLine($help);
exit(1);
}
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,27 @@
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^5.6",
"squizlabs/php_codesniffer": "^2.7",
"phpunit/phpunit": "^6.0.3",
"squizlabs/php_codesniffer": "^3.0",
"phpbench/phpbench": "^1.0@dev",
"bookdown/bookdown": "1.x-dev as 1.0.0",
"tobiju/bookdown-bootswatch-templates": "1.0.x-dev",
"malukenho/docheader": "^0.1.4"
"tobiju/bookdown-bootswatch-templates": "1.1",
"malukenho/docheader": "^0.1.5"
},
"suggest": {
"container-interop/container-interop": "To retrieve config in your factories"
"psr/container": "To retrieve config in your factories"
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "2.0-dev",
"dev-develop": "2.1-dev"
"dev-master": "2.1-dev",
"dev-develop": "2.2-dev"
}
},
"bin": [
"bin/interop-config"
],
"scripts": {
"check": [
"@cs",
Expand Down
66 changes: 66 additions & 0 deletions doc/book/console-tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Console Tools
Starting in 2.1.0, interop-config began shipping with console tools.

To get an overview of available commands run in your CLI `./vendor/bin/interop-config help`. This displays the following help message.

```bash
Usage:
command [options] [arguments]

Options:
-h, --help, help Display this help message

Available commands:
generate-config Generates options for the provided class name
display-config Displays current options for the provided class name
```

## generate-config
The `generate-config` command is pretty handy. It has never been so easy to create the configuration for a class which
uses one of the `Interop\Config` interfaces. Depending on implemented interfaces, a wizard will ask you for the option values.
It is also possible to update your current configuration. The value in brackets is used, if input is blank.

```bash
Usage:
generate-config [options] [<configFile>] [<className>]

Options:
-h, --help, help Display this help message

Arguments:
configFile Path to a config file or php://stdout for which to generate options.
className Name of the class to reflect and for which to generate options.

Reads the provided configuration file (creating it if it does not exist), and injects it with options for the provided
class name, writing the changes back to the file.
```
If your PHP config file is in the folder `config/global.php` and you have a class `My\AwesomeFactory` then you run
```bash
$ ./vendor/bin/interop-config generate-config config/global.php "My\AwesomeFactory"
```
## display-config
You can also see which options are set in the configuration file for a factory. If multiple configurations are supported
through the `Interop\Config\RequiresConfigId` you can enter a *config id* or leave it blank to display all configurations.
```bash
Usage:
display-config [options] [<configFile>] [<className>]

Options:
-h, --help, help Display this help message

Arguments:
configFile Path to a config file for which to display options. It must return an array / ArrayObject.
className Name of the class to reflect and for which to display options.

Reads the provided configuration file and displays options for the provided class name.
```
If your PHP config file is in the folder `config/global.php` and you have a class `My\AwesomeFactory` then you run
```bash
$ ./vendor/bin/interop-config display-config config/global.php "My\AwesomeFactory"
```
10 changes: 5 additions & 5 deletions doc/book/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This files contains examples for each interface. The factory class uses the `ConfigurationTrait` to retrieve options
from a configuration and optional to perform a mandatory option check or merge default options. There is also an
example for a independent config structure of the Zend Expressive TwigRendererFactory. The
[container-interop](https://github.com/container-interop/container-interop "Container Interoperability") specification
[psr-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md "Container Interoperability") specification
is used, so it's framework agnostic.

## Use a vendor.package.id config structure
Expand Down Expand Up @@ -42,7 +42,7 @@ Then you have easily access to the `orm_default` options in your method with `Co
```php
use Interop\Config\ConfigurationTrait;
use Interop\Config\RequiresConfigId;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyDBALConnectionFactory implements RequiresConfigId
{
Expand Down Expand Up @@ -105,7 +105,7 @@ option `driverClass` and `params` are available. So we also implement in the exa
use Interop\Config\ConfigurationTrait;
use Interop\Config\RequiresMandatoryOptions;
use Interop\Config\RequiresConfigId;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyDBALConnectionFactory implements RequiresConfigId, RequiresMandatoryOptions
{
Expand Down Expand Up @@ -161,7 +161,7 @@ to our factory. The magic is done via the `__callStatic()` method.
use Interop\Config\ConfigurationTrait;
use Interop\Config\RequiresMandatoryOptions;
use Interop\Config\RequiresConfigId;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyDBALConnectionFactory implements RequiresConfigId, RequiresMandatoryOptions
{
Expand Down Expand Up @@ -364,7 +364,7 @@ configuration file from the factory.
```php
namespace Zend\Expressive\Twig;

use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;
use Twig_Environment as TwigEnvironment;
use Twig_Extension_Debug as TwigExtensionDebug;
use Twig_ExtensionInterface;
Expand Down
6 changes: 3 additions & 3 deletions doc/book/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The suggested installation method is via composer. For composer documentation, p

Run `composer require sandrokeil/interop-config` to install interop-config.

It is recommended to use [container-interop](https://github.com/container-interop/container-interop) to retrieve the
It is recommended to use [psr-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md) to retrieve the
configuration in your factories.

## Config Structure
Expand Down Expand Up @@ -81,13 +81,13 @@ instance options follow. The following example uses `ConfigurationTrait` which i
options from a configuration. `RequiresConfigId` interface ensures support for more than one instance.

> Note that the configuration above is injected as `$config` in `options()` and
[container-interop](https://github.com/container-interop/container-interop) is used to retrieve the application configuration.
[psr-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md) is used to retrieve the application configuration.

```php
use Interop\Config\ConfigurationTrait;
use Interop\Config\RequiresConfigId;
use Interop\Config\RequiresMandatoryOptions;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyDBALConnectionFactory implements RequiresConfigId, RequiresMandatoryOptions
{
Expand Down
12 changes: 6 additions & 6 deletions doc/book/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ The factory gets a `ContainerInterface` ([Container PSR](https://github.com/php-
provided to retrieve the configuration.

> Note that the configuration above is injected as `$config` in `options()` and
[container-interop](https://github.com/container-interop/container-interop) is used to retrieve the application configuration.
[psr-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md) is used to retrieve the application configuration.

```php
use Interop\Config\RequiresConfigId;
use Interop\Config\ConfigurationTrait;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyAwesomeFactory implements RequiresConfigId
{
Expand Down Expand Up @@ -165,7 +165,7 @@ the developer gets an exact exception message with what is wrong. This is useful
use Interop\Config\RequiresConfigId;
use Interop\Config\RequiresMandatoryOptions;
use Interop\Config\ConfigurationTrait;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyAwesomeFactory implements RequiresConfigId, RequiresMandatoryOptions
{
Expand Down Expand Up @@ -208,7 +208,7 @@ use Interop\Config\RequiresConfigId;
use Interop\Config\RequiresMandatoryOptions;
use Interop\Config\ProvidesDefaultOptions;
use Interop\Config\ConfigurationTrait;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyAwesomeFactory implements RequiresConfigId, RequiresMandatoryOptions, ProvidesDefaultOptions
{
Expand Down Expand Up @@ -265,7 +265,7 @@ use Interop\Config\RequiresConfigId;
use Interop\Config\RequiresMandatoryOptions;
use Interop\Config\ProvidesDefaultOptions;
use Interop\Config\ConfigurationTrait;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyAwesomeFactory implements RequiresConfigId, RequiresMandatoryOptions, ProvidesDefaultOptions
{
Expand Down Expand Up @@ -301,7 +301,7 @@ use Interop\Config\RequiresConfigId;
use Interop\Config\RequiresMandatoryOptions;
use Interop\Config\ProvidesDefaultOptions;
use Interop\Config\ConfigurationTrait;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerInterface;

class MyAwesomeFactory implements RequiresConfigId, RequiresMandatoryOptions, ProvidesDefaultOptions
{
Expand Down
3 changes: 3 additions & 0 deletions doc/book/reference/bookdown.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
},
{
"tutorial": "../tutorial.md"
},
{
"console-tools": "../console-tools.md"
}
],
"target": "./html",
Expand Down
3 changes: 2 additions & 1 deletion doc/bookdown.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
],
"target": "./html",
"tocDepth": 2,
"numbering": false,
"template": "../vendor/tobiju/bookdown-bootswatch-templates/templates/main.php",
"copyright": "Visit interop-config on <a href=\"https://github.com/sandrokeil/interop-config\" title=\"interop-config on GitHub\">GitHub</a><br/>Copyright (c) 2015-2016 <a href=\"https://sandro-keil.de/\" title=\"I write about topics, advices and trends of web development\">Sandro Keil</a> <br/> Powered by <a href=\"https://github.com/tobiju/bookdown-bootswatch-templates\" title=\"Visit project to generate your own docs\">Bookdown Bootswatch Templates</a>"
"copyright": "Visit interop-config on <a href=\"https://github.com/sandrokeil/interop-config\" title=\"interop-config on GitHub\">GitHub</a><br/>Copyright (c) 2015-2017 <a href=\"https://sandro-keil.de/\" title=\"I write about topics, advices and trends of web development\">Sandro Keil</a> <br/> Powered by <a href=\"https://github.com/tobiju/bookdown-bootswatch-templates\" title=\"Visit project to generate your own docs\">Bookdown Bootswatch Templates</a>"
}
Loading

0 comments on commit 195e553

Please sign in to comment.