suhailparad/lara-command-chain

Run predefined chains of commands in Laravel

Maintainers

Package info

github.com/suhailparad/lara-command-chain

pkg:composer/suhailparad/lara-command-chain

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v1.0.0 2025-09-11 09:58 UTC

This package is auto-updated.

Last update: 2026-04-11 11:23:30 UTC


README

License: MIT

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

  1. Require the package in your Laravel project (local or via Packagist):
composer require suhailparad/lara-command-chain
  1. (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 install or composer 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

  1. Fork the repository.
  2. Create your feature branch: git checkout -b feature/new-chain.
  3. Commit your changes: git commit -m 'Add new chain feature'.
  4. Push to the branch: git push origin feature/new-chain.
  5. Submit a pull request.

βš–οΈ License

MIT License Β© Muhammed Suhail