chubbyphp/chubbyphp-lazy-command
Chubbyphp Lazy Command
1.3.1
2019-11-29 14:38 UTC
Requires
- php: ^7.0
- psr/container: ^1.0
- symfony/console: ^2.8|^3.4|^4.2|^5.0
Requires (Dev)
- chubbyphp/chubbyphp-mock: ^1.4.2
- container-interop/container-interop: ^1.2
- friendsofphp/php-cs-fixer: ^2.16.1
- php-coveralls/php-coveralls: ^2.2
- phploc/phploc: ^4.0.1||^5.0
- phpunit/phpunit: ^6.5.14|^7.5.17|^8.4.3
README
Description
Allow to lazyload commands.
Requirements
- php: ^7.0
- psr/container: ^1.0
- symfony/console: ^2.8|^3.4|^4.2|^5.0
Installation
Through Composer as chubbyphp/chubbyphp-lazy-command.
composer require chubbyphp/chubbyphp-lazy-command "^1.3"
Usage
For callables
<?php use Chubbyphp\Lazy\LazyCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; $container['service'] = function () { return function (InputInterface $input, OutputInterface $output) { // run some lazy logic }; }; $command = new LazyCommand( $container, 'service', 'name', [ new InputArgument('argument'), ], 'description', 'help' ); $command->run();
For existing commands extending Command
<?php use Chubbyphp\Lazy\CommandAdapter; use Chubbyphp\Lazy\LazyCommand; use Symfony\Component\Console\Input\InputArgument; $container['service'] = function () { return new CommandAdapter(new ExistingCommand()); }; $command = new LazyCommand( $container, 'service', 'name', [ new InputArgument('argument'), ], 'description', 'help' ); $command->run();
Copyright
Dominik Zogg 2019