chubbyphp / chubbyphp-lazy-command
此包已被弃用且不再维护。未建议替代包。
Chubbyphp Lazy Command
1.4.0
2020-08-18 19:38 UTC
Requires
- php: ^7.2
- psr/container: ^1.0
- symfony/console: ^3.4.43|^4.4.11|^5.0
Requires (Dev)
- chubbyphp/chubbyphp-dev-helper: dev-master
- chubbyphp/chubbyphp-mock: ^1.4.5
- infection/infection: ^0.15.3|^0.16.4
- laminas/laminas-container-config-test: ^0.2 || ^1.0
- mavimo/phpstan-junit: ^0.3
- php-coveralls/php-coveralls: ^2.2
- phploc/phploc: ^5.0|^6.0.2
- phpstan/extension-installer: ^1.0.4
- phpstan/phpstan: ^0.12.33
- phpunit/phpunit: ^8.5.8|^9.2.6
README
描述
允许懒加载命令。
要求
- php: ^7.2
- psr/container: ^1.0
- symfony/console: ^3.4.43|^4.4.11|^5.0
安装
通过 Composer 作为 chubbyphp/chubbyphp-lazy-command 安装。
composer require chubbyphp/chubbyphp-lazy-command "^1.4"
用法
对于可调用者
<?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();
对于扩展 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();
版权
Dominik Zogg 2020