定制 suhailparad/lara-command-chain 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

suhailparad/lara-command-chain

最新稳定版本:v1.0.0

Composer 安装命令:

composer require suhailparad/lara-command-chain

包简介

Run predefined chains of commands in Laravel

README 文档

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

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-11