Allow to lazyload commands.
- php: ^7.2
- psr/container: ^1.0
- symfony/console: ^3.4.43|^4.4.11|^5.0
Through Composer as chubbyphp/chubbyphp-lazy-command.
composer require chubbyphp/chubbyphp-lazy-command "^1.4"<?phpuseChubbyphp\Lazy\LazyCommand;
useSymfony\Component\Console\Input\InputInterface;
useSymfony\Component\Console\Input\InputArgument;
useSymfony\Component\Console\Output\OutputInterface;
$container['service'] = function () {
returnfunction (InputInterface$input, OutputInterface$output) {
// run some lazy logic
};
};
$command = newLazyCommand(
$container,
'service',
'name',
[
newInputArgument('argument'),
],
'description',
'help'
);
$command->run();<?phpuseChubbyphp\Lazy\CommandAdapter;
useChubbyphp\Lazy\LazyCommand;
useSymfony\Component\Console\Input\InputArgument;
$container['service'] = function () {
returnnewCommandAdapter(newExistingCommand());
};
$command = newLazyCommand(
$container,
'service',
'name',
[
newInputArgument('argument'),
],
'description',
'help'
);
$command->run();Dominik Zogg 2020


