1. Go to this page and download the library: Download phlib/console-configuration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phlib / console-configuration example snippets
// your usual cli setup script
use Phlib\ConsoleConfiguration\Helper\ConfigurationHelper;
$app = new Application('my-cli');
$app->setCommands(['...']);
$helper = ConfigurationHelper::initHelper(
$app,
$default = ['host' => 'localhost'],
$options = []
);
$app->run();
class MyCommand extends Command
{
'...'
protected function createMyObjectInstance()
{
$config = $this->getHelper('configuration')->fetch();
return new MyObjectInstance($config);
}
}