Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/veewee/composer-run-parallel
Run composer tasks in parallel
https://github.com/veewee/composer-run-parallel
composer parallel scripts
Last synced: 6 days ago
JSON representation
Run composer tasks in parallel
- Host: GitHub
- URL: https://github.com/veewee/composer-run-parallel
- Owner: veewee
- License: mit
- Created: 2020-11-27T15:50:22.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-04T12:21:31.000Z (about 1 year ago)
- Last Synced: 2024-04-29T16:20:27.952Z (6 months ago)
- Topics: composer, parallel, scripts
- Language: PHP
- Homepage:
- Size: 7.9 MB
- Stars: 81
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Composer run parallel
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.](https://veewee.github.io/blog/run-composer-tasks-in-parallel/)
## Installation
```bash
composer require --dev veewee/composer-run-parallel
```or globally ...
```bash
composer require --global veewee/composer-run-parallel
```## Examples
```json
{
"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:
```bash
composer run parallel php1 php2
```You can even create a shortcut script for the parallel function like this:
```json
{
"scripts": {
"php1": "@php -r 'sleep(3); echo \"1\";'",
"php2": "@php -r 'echo \"2\";'",
"php1And2": "@parallel php1 php2"
}
}
``````bash
composer run php1And2
```What if a task fails?
```json
{
"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:
```bash
composer run parallel php1 phpfailSuccesfully ran:
php1Failed running:
phpfailNot all tasks could be executed succesfully!
```*Note*: You can also use the shorthand command:
```bash
composer parallel php1 phpfail
```Pretty cool right?
What If I told you there is even more?!```json
{
"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