suhailparad / lara-command-chain
Run predefined chains of commands in Laravel
v1.0.0
2025-09-11 09:58 UTC
Requires
- php: >=8.0
README
Run predefined chains of Artisan and shell commands in your Laravel application with a single command.
This package allows you to define βchainsβ of commands (both Artisan and shell commands like npm install or composer update) and run them sequentially in a clean, visual way in your terminal.
π¦ Installation
- Require the package in your Laravel project (local or via Packagist):
composer require suhailparad/lara-command-chain
- (Optional) If developing locally, add repository path in
composer.json:
"repositories": [ { "type": "path", "url": "packages/lara-command-chain" } ]
βοΈ Publish Configuration
php artisan vendor:publish --tag=command-chain-config
This will publish config/command-chain.php where you can define your chains.
π Configuration
config/command-chain.php example:
return [ 'chains' => [ 'setup' => [ 'php artisan migrate:fresh', 'php artisan db:seed', 'php artisan cache:clear', ], 'deploy' => [ 'php artisan down', 'composer update', 'npm install', 'php artisan migrate', 'php artisan up', ], ], ];
- Each chain is a named array of commands.
- Commands can be Artisan commands (
php artisan ...) or shell commands (npm install,composer update,git pull, etc.).
π Usage
Run a chain:
php artisan chain:run setup php artisan chain:run deploy
Output Example
β‘ Running chain: deploy [1/4] php artisan down ... β done (0.1s) [2/4] composer update ... π running... Updating dependencies... Generating optimized autoload files... [2/4] composer update ... β done (6.3s) [3/4] php artisan migrate ... β done (0.2s) [4/4] php artisan up ... β done (0.1s) β‘ Chain [deploy] completed!
π Dry Run
Check what commands would run without executing:
php artisan chain:run deploy --dry-run
Example output:
βοΈ [1/4] php artisan down ... skipped (dry run) βοΈ [2/4] composer update ... skipped (dry run) βοΈ [3/4] php artisan migrate ... skipped (dry run) βοΈ [4/4] php artisan up ... skipped (dry run)
π§ Features
- Run multiple Artisan or shell commands in sequence.
- β Shows status (done / failed / skipped) with icons.
- β± Shows duration for each command.
- Dry-run support (
--dry-run) to preview chains. - Works with long-running commands like
npm installorcomposer update. - Fully configurable via
config/command-chain.php.
β‘ Example Chains
'chains' => [ 'build' => [ 'npm install', 'npm run build', ], 'deploy' => [ 'php artisan down', 'composer install', 'php artisan migrate', 'php artisan up', ], ];
Run them:
php artisan chain:run build php artisan chain:run deploy
π Contribution
- Fork the repository.
- Create your feature branch:
git checkout -b feature/new-chain. - Commit your changes:
git commit -m 'Add new chain feature'. - Push to the branch:
git push origin feature/new-chain. - Submit a pull request.
βοΈ License
MIT License Β© Muhammed Suhail