Skip to content

Commit 195e553

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 74fc934 + d8e9fe8 commit 195e553

58 files changed

Lines changed: 2429 additions & 73 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.docheader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
* Sandro Keil (https://sandro-keil.de)
33
*
44
* @link http://github.com/sandrokeil/interop-config for the canonical source repository
5-
* @copyright Copyright (c) 2015-2016 Sandro Keil
5+
* @copyright Copyright (c) 20%regexp:\d{2}%-%year% Sandro Keil
66
* @license http://github.com/sandrokeil/interop-config/blob/master/LICENSE.md New BSD License
77
*/

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ matrix:
1919
- EXECUTE_TEST_COVERALLS=true
2020
- EXECUTE_CS_CHECK=true
2121
- EXECUTE_DOCHEADER_CHECK=true
22-
- php: hhvm
2322
allow_failures:
2423
- php: hhvm
2524

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

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

5+
## 2.1.0 (2017-02-14)
6+
7+
### Added
8+
9+
* [#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).
10+
* Composer suggestion of `psr/container`
11+
12+
### Deprecated
13+
14+
* Nothing
15+
16+
### Removed
17+
18+
* Composer suggestion of `container-interop/container-interop`
19+
20+
### Fixed
21+
22+
* Nothing
23+
24+
525
## 2.0.1 (2016-12-09)
626
This release contains **no** BC break.
727

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Documentation is [in the doc tree](doc/), and can be compiled using [bookdown](h
5151

5252
```console
5353
$ docker run -it --rm -v $(pwd):/app sandrokeil/bookdown doc/bookdown.json
54-
$ 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
54+
$ 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
5555
```
5656

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

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

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

8074
## Benchmarks
8175
The benchmarks uses [PHPBench](http://phpbench.readthedocs.org/en/latest/) and can be started by the following command:

bin/interop-config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env php
2+
<?php
3+
require 'interop-config.php';

bin/interop-config.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Sandro Keil (https://sandro-keil.de)
4+
*
5+
* @link http://github.com/sandrokeil/interop-config for the canonical source repository
6+
* @copyright Copyright (c) 2017 Sandro Keil
7+
* @license http://github.com/sandrokeil/interop-config/blob/master/LICENSE.md New BSD License
8+
*/
9+
10+
namespace Interop\Config;
11+
12+
// Setup/verify autoloading
13+
use Interop\Config\Tool\ConsoleHelper;
14+
15+
if (file_exists($a = getcwd() . '/vendor/autoload.php')) {
16+
require $a;
17+
} elseif (file_exists($a = __DIR__ . '/../../../autoload.php')) {
18+
require $a;
19+
} elseif (file_exists($a = __DIR__ . '/../vendor/autoload.php')) {
20+
require $a;
21+
} else {
22+
fwrite(STDERR, 'Cannot locate autoloader; please run "composer install"' . PHP_EOL);
23+
exit(1);
24+
}
25+
26+
$argv = array_slice($argv, 1);
27+
28+
$command = array_shift($argv);
29+
30+
$help = <<<EOF
31+
<info>Usage:</info>
32+
command [options] [arguments]
33+
34+
<info>Options:</info>
35+
<value>-h, --help, help</value> Display this help message
36+
37+
<info>Available commands:</info>
38+
<value>generate-config</value> Generates options for the provided class name
39+
<value>display-config</value> Displays current options for the provided class name
40+
EOF;
41+
42+
try {
43+
switch ($command) {
44+
case 'display-config':
45+
$command = new Tool\ConfigReaderCommand();
46+
$status = $command($argv);
47+
exit($status);
48+
case 'generate-config':
49+
$command = new Tool\ConfigDumperCommand();
50+
$status = $command($argv);
51+
exit($status);
52+
case '-h':
53+
case '--help':
54+
case 'help':
55+
$consoleHelper = new ConsoleHelper();
56+
$consoleHelper->writeLine($help);
57+
exit(0);
58+
default:
59+
$consoleHelper = new ConsoleHelper();
60+
$consoleHelper->writeErrorMessage(strip_tags($help));
61+
exit(1);
62+
}
63+
} catch (\Throwable $e) {
64+
$consoleHelper = new ConsoleHelper();
65+
$consoleHelper->writeErrorMessage($e->getMessage());
66+
$consoleHelper->writeLine($help);
67+
exit(1);
68+
}

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,27 @@
4242
"php": "^7.1"
4343
},
4444
"require-dev": {
45-
"phpunit/phpunit": "^5.6",
46-
"squizlabs/php_codesniffer": "^2.7",
45+
"phpunit/phpunit": "^6.0.3",
46+
"squizlabs/php_codesniffer": "^3.0",
4747
"phpbench/phpbench": "^1.0@dev",
4848
"bookdown/bookdown": "1.x-dev as 1.0.0",
49-
"tobiju/bookdown-bootswatch-templates": "1.0.x-dev",
50-
"malukenho/docheader": "^0.1.4"
49+
"tobiju/bookdown-bootswatch-templates": "1.1",
50+
"malukenho/docheader": "^0.1.5"
5151
},
5252
"suggest": {
53-
"container-interop/container-interop": "To retrieve config in your factories"
53+
"psr/container": "To retrieve config in your factories"
5454
},
5555
"minimum-stability": "dev",
5656
"prefer-stable": true,
5757
"extra": {
5858
"branch-alias": {
59-
"dev-master": "2.0-dev",
60-
"dev-develop": "2.1-dev"
59+
"dev-master": "2.1-dev",
60+
"dev-develop": "2.2-dev"
6161
}
6262
},
63+
"bin": [
64+
"bin/interop-config"
65+
],
6366
"scripts": {
6467
"check": [
6568
"@cs",

doc/book/console-tools.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Console Tools
2+
Starting in 2.1.0, interop-config began shipping with console tools.
3+
4+
To get an overview of available commands run in your CLI `./vendor/bin/interop-config help`. This displays the following help message.
5+
6+
```bash
7+
Usage:
8+
command [options] [arguments]
9+
10+
Options:
11+
-h, --help, help Display this help message
12+
13+
Available commands:
14+
generate-config Generates options for the provided class name
15+
display-config Displays current options for the provided class name
16+
```
17+
18+
## generate-config
19+
The `generate-config` command is pretty handy. It has never been so easy to create the configuration for a class which
20+
uses one of the `Interop\Config` interfaces. Depending on implemented interfaces, a wizard will ask you for the option values.
21+
It is also possible to update your current configuration. The value in brackets is used, if input is blank.
22+
23+
```bash
24+
Usage:
25+
generate-config [options] [<configFile>] [<className>]
26+
27+
Options:
28+
-h, --help, help Display this help message
29+
30+
Arguments:
31+
configFile Path to a config file or php://stdout for which to generate options.
32+
className Name of the class to reflect and for which to generate options.
33+
34+
Reads the provided configuration file (creating it if it does not exist), and injects it with options for the provided
35+
class name, writing the changes back to the file.
36+
```
37+
38+
If your PHP config file is in the folder `config/global.php` and you have a class `My\AwesomeFactory` then you run
39+
40+
```bash
41+
$ ./vendor/bin/interop-config generate-config config/global.php "My\AwesomeFactory"
42+
```
43+
44+
## display-config
45+
You can also see which options are set in the configuration file for a factory. If multiple configurations are supported
46+
through the `Interop\Config\RequiresConfigId` you can enter a *config id* or leave it blank to display all configurations.
47+
48+
```bash
49+
Usage:
50+
display-config [options] [<configFile>] [<className>]
51+
52+
Options:
53+
-h, --help, help Display this help message
54+
55+
Arguments:
56+
configFile Path to a config file for which to display options. It must return an array / ArrayObject.
57+
className Name of the class to reflect and for which to display options.
58+
59+
Reads the provided configuration file and displays options for the provided class name.
60+
```
61+
62+
If your PHP config file is in the folder `config/global.php` and you have a class `My\AwesomeFactory` then you run
63+
64+
```bash
65+
$ ./vendor/bin/interop-config display-config config/global.php "My\AwesomeFactory"
66+
```

doc/book/examples.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This files contains examples for each interface. The factory class uses the `ConfigurationTrait` to retrieve options
44
from a configuration and optional to perform a mandatory option check or merge default options. There is also an
55
example for a independent config structure of the Zend Expressive TwigRendererFactory. The
6-
[container-interop](https://github.com/container-interop/container-interop "Container Interoperability") specification
6+
[psr-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md "Container Interoperability") specification
77
is used, so it's framework agnostic.
88

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

4747
class MyDBALConnectionFactory implements RequiresConfigId
4848
{
@@ -105,7 +105,7 @@ option `driverClass` and `params` are available. So we also implement in the exa
105105
use Interop\Config\ConfigurationTrait;
106106
use Interop\Config\RequiresMandatoryOptions;
107107
use Interop\Config\RequiresConfigId;
108-
use Interop\Container\ContainerInterface;
108+
use Psr\Container\ContainerInterface;
109109

110110
class MyDBALConnectionFactory implements RequiresConfigId, RequiresMandatoryOptions
111111
{
@@ -161,7 +161,7 @@ to our factory. The magic is done via the `__callStatic()` method.
161161
use Interop\Config\ConfigurationTrait;
162162
use Interop\Config\RequiresMandatoryOptions;
163163
use Interop\Config\RequiresConfigId;
164-
use Interop\Container\ContainerInterface;
164+
use Psr\Container\ContainerInterface;
165165

166166
class MyDBALConnectionFactory implements RequiresConfigId, RequiresMandatoryOptions
167167
{
@@ -364,7 +364,7 @@ configuration file from the factory.
364364
```php
365365
namespace Zend\Expressive\Twig;
366366

367-
use Interop\Container\ContainerInterface;
367+
use Psr\Container\ContainerInterface;
368368
use Twig_Environment as TwigEnvironment;
369369
use Twig_Extension_Debug as TwigExtensionDebug;
370370
use Twig_ExtensionInterface;

doc/book/intro.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The suggested installation method is via composer. For composer documentation, p
4141

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

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

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

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

8686
```php
8787
use Interop\Config\ConfigurationTrait;
8888
use Interop\Config\RequiresConfigId;
8989
use Interop\Config\RequiresMandatoryOptions;
90-
use Interop\Container\ContainerInterface;
90+
use Psr\Container\ContainerInterface;
9191

9292
class MyDBALConnectionFactory implements RequiresConfigId, RequiresMandatoryOptions
9393
{

0 commit comments

Comments
 (0)