Skip to content

Repository files navigation

chubbyphp-lazy-command

Build StatusCoverage StatusLatest Stable VersionTotal DownloadsMonthly DownloadsDaily Downloads

Description

Allow to lazyload commands.

Requirements

  • php: ^7.2
  • psr/container: ^1.0
  • symfony/console: ^3.4.43|^4.4.11|^5.0

Installation

Through Composer as chubbyphp/chubbyphp-lazy-command.

composer require chubbyphp/chubbyphp-lazy-command "^1.4"

Usage

For callables

<?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();

For existing commands extending Command

<?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();

Copyright

Dominik Zogg 2020

About

Allow to lazyload commands

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages