定制 sabatino/artisan-dev 二次开发

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

邮箱: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.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固