-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop'
- Loading branch information
Showing
58 changed files
with
2,429 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
require 'interop-config.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.