veewee / composer-run-parallel
Run composer tasks in parallel
Fund package maintenance!
veewee
Installs: 531 634
Dependents: 7
Suggesters: 0
Security: 0
Stars: 86
Watchers: 4
Forks: 4
Open Issues: 0
Type:composer-plugin
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0
- composer-plugin-api: ~2.0
Requires (Dev)
- composer/composer: ^2.0
- react/promise: 1.2.1
- symfony/process: 2.8.52
README
This composer plugin allows you to run the tasks inside your composer file in parallel. No more waiting on one specific task!
Please find my blog post describing the whole story.
Installation
composer require --dev veewee/composer-run-parallel
or globally ...
composer require --global veewee/composer-run-parallel
Examples
{ "scripts": { "php1": "@php -r 'sleep(3); echo \"1\";'", "php2": "@php -r 'echo \"2\";'" } }
Following command will result in parallel execution of both php1 and php2:
composer run parallel php1 php2
You can even create a shortcut script for the parallel function like this:
{ "scripts": { "php1": "@php -r 'sleep(3); echo \"1\";'", "php2": "@php -r 'echo \"2\";'", "php1And2": "@parallel php1 php2" } }
composer run php1And2
What if a task fails?
{ "scripts": { "php1": "@php -r 'sleep(3); echo \"1\";'", "phpfail": "@php -r 'throw new Exception(\"FAIL\");'" } }
All tasks will be executed and if one fails, the parallel task will fail as well:
composer run parallel php1 phpfail
Succesfully ran:
php1
Failed running:
phpfail
Not all tasks could be executed succesfully!
Note: You can also use the shorthand command:
composer parallel php1 phpfail
Pretty cool right? What If I told you there is even more?!
{ "scripts": { "wicked": [ "@parallel vendor php2", "@php1" ] } }
You can even mix parallel tasks with serial tasks and even nest multiple parallel tasks at the same time. This way you can create flows like:
- do some checks first
- next run some stuff in parallel
- finish up with some blocking cleanup task if everything was ok