sabatino/artisan-dev 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sabatino/artisan-dev

最新稳定版本:1.0.0

Composer 安装命令:

composer require sabatino/artisan-dev

包简介

Helper for running multiple dev scripts in Laravel

README 文档

README

Run multiple scripts in parallel from a single command, with integrated logging.

Installation

composer require sabatino/artisan-dev

This package publishes a dev-scripts config file:

php artisan vendor:publish --tag=dev-services

Configuration

Define your scripts in the dev-scripts.php config file, eg:

<?php

return [
    'scripts' => [
        'horizon' => [
            'command' => ['php', 'artisan', 'horizon'],
            'style' => ['cyan', null, ['bold']],
            'logging' => true,
            'log_options' => [
                'apply_style_to_full_line' => true
            ],
            'restart' => [
                'logging' => true,
                'watch' => [
                    '.env',
                    'app/Jobs/*'
                ]
            ]
        ],
        'reverb' => [
            'command' => ['php', 'artisan', 'reverb:start', '--verbose', '--debug'],
            'style' => ['magenta', null, ['bold']],
            'logging' => true,
        ],
    ]
];

Usage

Run the scripts with the php artisan dev command:

php artisan dev

File watcher

The restart.watch option allows you to define a list of directories/files to watch. Changes to these files will trigger a restart of the script. This feature is powered by the Javascript file watcher Chokidar, you can install it as follows:

NPM:

npm install chokidar

Yarn:

yarn add chokidar

Logging

You can enable logging for each script by setting the logging option to true. Logs will be shown in the console and will be prefixed with the script name. To make the logs more readable, you can define a style for each script.

[
    'style' => ['magenta', null, ['bold']],
]

Log options

'log_options' => [
    // Apply the style to the full line, not just the script name
    'apply_style_to_full_line' => true
],

These parameters are passed into the constructor of Symfony\Component\Console\Formatter\OutputFormatterStyle, you can refer to the documentation here: https://symfony.com/doc/current/console/coloring.html

Working Directory

You can change the working directory for each script by setting the working_directory option. When combining the working_directory option with the restart.watch option, the paths in the restart.watch option should be relative to the working_directory.

'working_directory' => 'path/to/working/directory',

ENV:

By default, all scripts will run with the same environment variables as the parent process. When using the working_directory option, you can define a custom .env file in that directory to be used for that process instead of the default environment variables.

Credits

file-watcher: https://github.com/spatie/file-system-watcher/blob/main/bin/file-watcher.js

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-02