library cli
Hack command line application container created for Decouple Framework.
decouple/cli
Hack command line application container created for Decouple Framework.
- Saturday, February 18, 2017
- by phenocode
- Repository
- 1 Watchers
- 0 Stars
- 35 Installations
- Hack
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
decouple/cli
Hack command line application container created for Decouple Framework., (*1)
Usage
<?hh // partial
use Decouple\CLI\App;
use Decouple\CLI\Request\Request;
use Decouple\Decoupler\Decoupler;
use Decouple\Registry\Paths;
use Decouple\Log\Log;
// Define a vector of valid commands
$commands = Vector {
"Decouple\Test\TestCommand",
"Decouple\DBAL_CLI\Command\MigrateUpCommand",
"Decouple\DBAL_CLI\Command\MigrateDownCommand",
"Decouple\DBAL_CLI\Command\MigrateRefreshCommand",
"Decouple\DBAL_CLI\Command\SeedCommand"
};
// Remove the name of the binary .hh
$args = new Vector($argv);
if($args->get(0) == 'decouple.hh') { $args->removeKey(0); }
// Create the CLI Request
$request = new Request($args);
// Create a Decoupler injector instance
$decoupler = new Decoupler(Map {});
// Register a $paths container containing at least a path to the "config" dir
$paths = new Paths(Map {
"config" => "/path/to/configs"
});
// Create the CLI App with the given Request,
$app = new App($request, $decoupler, new Paths($paths), $commands);
/**
* Using the Decoupler you can now add a parameter with any of the types below
* to your Command constructors and it will be automatically injected
*/
$services = Map {
"Decouple\Log\Log" => new Log((string)$paths->get('logs') . "/cli.log"),
"Decouple\Registry\Paths" => new Paths($paths),
"Decouple\CLI\Request\Request" => $request
};
$app->addServices($services);
$app->execute();
dev-master
9999999-dev
Hack command line application container created for Decouple Framework.
Sources
Download
MIT
The Requires
by
Andrew Ewing