jnjxp / console
Simple PHP Console
dev-develop
2017-05-25 18:24 UTC
Requires
- psr/log: ^1.0
This package is auto-updated.
Last update: 2024-10-26 09:16:07 UTC
README
Really simple commandline interface
Usage
Console
/** * Some Commands */ class HelloWorld { public function __invoke($name = 'World') { echo "Hello $name" . PHP_EOL; return \Jnjxp\Console\Status::SUCCESS; } } class ByeWorld { public function __invoke($name = 'World') { echo "Bye $name" . PHP_EOL; return \Jnjxp\Console\Status::SUCCESS; } } /** * Create an application */ $console = new Jnjxp\Console\Console( [ 'hi' => HelloWorld::class, 'bye' => ByeWorld::class ] ); // Execute based on input and exit $status = $console($argv); exit($status);
StdLog
See: http://paul-m-jones.com/archives/6552
$log = new \Jnjxp\Console\StdLog; $log->setLevel(\Psr\Log\LogLevel::INFO); $log->debug('This wont print cuz level'); $log->info('Prints to stdout'); $log->error('Prints to STDERR');