定制 esign/laravel-install-command 二次开发

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

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

esign/laravel-install-command

Composer 安装命令:

composer require esign/laravel-install-command

包简介

Simplify stub publishing and effortlessly manage Composer and Node packages

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

This package provides a simple way to publish stubs and install Composer and Node packages using a Laravel Command. This may be useful when creating packages that require stubs to be publish and require Composer and Node packages to be installed.

Installation

You can install the package via composer:

composer require esign/laravel-install-command

Usage

To make use of the InstallJob you may create a new command that extends the InstallCommand class. In this command you may specify the stubs to publish and the Composer and Node packages to install.

use Esign\InstallCommand\InstallCommand;
use Esign\InstallCommand\ValueObjects\AppendableFile;
use Esign\InstallCommand\ValueObjects\ComposerPackage;
use Esign\InstallCommand\ValueObjects\NodePackage;
use Esign\InstallCommand\ValueObjects\PublishableFile;
use Esign\InstallCommand\ValueObjects\PublishableFolder;

class MyInstallCommand extends InstallCommand
{
    protected $signature = 'my-install-command';
    protected $description = 'Publish my stubs and install my packages';

    protected function publishableFiles(): array
    {
        return [
            new PublishableFile(
                path: __DIR__ . '/../../stubs/my-stub.stub',
                target: base_path('my-stub.php'),
            ),
            new PublishableFolder(
                path: __DIR__ . '/../../stubs/resources',
                target: base_path('resources'),
            ),
            new AppendableFile(
                path: __DIR__ . '/../../stubs/my-appendable-stub.stub',
                target: base_path('my-appendable-stub.php'),
            ),
            new AppendableFile(
                path: __DIR__ . '/../../stubs/my-appendable-stub.stub',
                target: base_path('my-appendable-stub.php'),
                search: 'insert-after-line-with-this-string',
            ),
        ];
    }

    protected function composerPackages(): array
    {
        return [
            new ComposerPackage(name: 'my/composer-package'),
            new ComposerPackage(name: 'my/specific-composer-package', version: '^1.0'),
            new ComposerPackage(name: 'my/dev-composer-package', dev: true),
        ];
    }

    protected function nodePackages(): array
    {
        return [
            new NodePackage(name: 'my/node-package'),
            new NodePackage(name: 'my/specific-node-package', version: '^1.0'),
            new NodePackage(name: 'my/dev-node-package', dev: true),
        ];
    }
}

Publishing behavior

By default, file publishing is conservative:

  • PublishableFile: publishes the file only when the target file does not already exist.
  • PublishableFolder: evaluates files inside the folder individually. Missing files are published, existing files are skipped.
  • AppendableFile: appends content when the target file does not exist yet, or when the appendable content is not already present.

If you run the command with --force, the installer becomes aggressive:

  • existing published files are overwritten
  • existing files inside published folders are overwritten
  • appendable content is appended again, even if it is already present

Filtering files

You can pass --filter one or more times to publish only files whose target path contains any of the given strings (case-insensitive):

php artisan my-install-command --filter=Services
php artisan my-install-command --filter=Services --filter=Models

This is useful when you want to re-publish specific files without running the full install. Note that --filter only affects file publishing; Composer and Node package installation is unaffected.

Publish overview

After publishing files, the command prints an overview of what happened:

📄 Publish overview: 3 published, 1 skipped.
Published files:
 + /path/to/source.stub -> /path/to/target.php
Skipped files:
 - /path/to/source.stub -> /path/to/target.php

This makes it easier to see which files were created, overwritten, appended, or skipped during installation.

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

esign/laravel-install-command 适用场景与选型建议

esign/laravel-install-command 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.77k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「esign」 「install-command」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 esign/laravel-install-command 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 esign/laravel-install-command 我们能提供哪些服务?
定制开发 / 二次开发

基于 esign/laravel-install-command 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-21