fichtme / symfony-command-runner
Run multiple commands async
Installs: 8 424
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|~8.0
- doctrine/collections: ^1.6
- symfony/console: ^5.2 || ^6 || ^7
- symfony/lock: ^5.2 || ^6
- symfony/process: ^5.2 || ^6 || ^7
Requires (Dev)
- phpunit/phpunit: ^9
- symfony/debug: ^4.4 || ^6 || ^7
README
Run multiple commands in another process and wait for completion.
Usage
(new CommandRunner([ new Process("my:command -q"), new Process("my:command2 -q"), new Process("my:command3 -q"). new Process("my:command4 -q"), new Process("my:command5 -q"), new Process("my:command6 -q --env=$env"), ])) ->continueOnError(true) ->setIO($this->io) ->setLimit(3) ->run();
Possible use case:
/** * Class UpdateCommand * * @package App\Command\Update */ class UpdateCommand extends AbstractCommand { /** * Configures the current command. */ protected function configure() { $this->setName('app:update') ->setDescription('execute updates'); } /** * @param InputInterface $input * @param OutputInterface $output * * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->io->writeln('Running update scripts'); sleep(5); # Sleep so user can abort update (new CommandRunner([ new Process("my:command -q"), new Process("my:command2 -q"), new Process("my:command3 -q"). new Process("my:command4 -q"), new Process("my:command5 -q"), new Process("my:command6 -q"), ])) ->continueOnError(true) ->setIO($this->io) ->setLimit(3) ->run(); return 0; } }