定制 laravel-enso/upgrade 二次开发

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

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

laravel-enso/upgrade

Composer 安装命令:

composer require laravel-enso/upgrade

包简介

Helper classes dependency for Laravel Enso

README 文档

README

License Stable Downloads PHP Issues Merge Requests

Description

Upgrade orchestrates both package-level upgrade routines across the Laravel Enso ecosystem and local project upgrade routines defined inside the host application.

It discovers upgrade classes from the application and from configured vendor packages, sorts them by priority and last modification date, and executes them through a consistent pipeline that supports table migrations, data migrations, post-data migration steps, rollback hooks, manual-only upgrades, and before-migration upgrades.

The package also includes a structure-upgrade adapter for permission and role provisioning, plus a status command that reports upgrade applicability, execution mode, ordering, and migration state.

Installation

This package is normally installed as part of the Enso core stack.

For standalone installation in an Enso-based application:

composer require laravel-enso/upgrade

The package registers:

  • enso:upgrade
  • enso:upgrade:status

If needed, you can publish the config with:

php artisan vendor:publish --tag=upgrade-config

Default configuration:

return [
    'folders' => ['.'],
    'vendors' => ['laravel-enso'],
];

Features

  • Discovers upgrade classes from local folders and configured vendor namespaces.
  • Supports package upgrades implemented as PHP classes instead of one-off scripts.
  • Sorts upgrades by explicit priority and then by last modified timestamp.
  • Supports pre-migration upgrades through the BeforeMigration marker interface.
  • Supports manual-only upgrades through the ShouldRunManually marker interface.
  • Supports conditional execution through the Applicable contract.
  • Executes table, data, and post-data migration steps in a controlled sequence.
  • Rolls back table changes when a data or post-data migration fails and the upgrade implements rollback support.
  • Wraps structure upgrades into permission and role synchronization workflows.
  • Provides a status table for debugging pending, manual, or already-ran upgrades.

Usage

Run all applicable upgrades:

php artisan enso:upgrade

Run manual upgrades as well:

php artisan enso:upgrade --manual

Run only upgrades meant to execute before the main database migration flow:

php artisan enso:upgrade --before-migration

Inspect the current upgrade inventory and status:

php artisan enso:upgrade:status

A minimal upgrade class can implement MigratesTable:

use Illuminate\Support\Facades\Schema;
use LaravelEnso\Upgrade\Contracts\MigratesTable;

class AddStatusColumn implements MigratesTable
{
    public function isMigrated(): bool
    {
        return Schema::hasColumn('orders', 'status');
    }

    public function migrateTable(): void
    {
        Schema::table('orders', function ($table) {
            $table->string('status')->nullable();
        });
    }
}

Structure upgrades can declare permissions and optional roles:

use LaravelEnso\Upgrade\Contracts\MigratesStructure;
use LaravelEnso\Upgrade\Traits\StructureMigration;

class OrdersStructureUpgrade implements MigratesStructure
{
    use StructureMigration;

    protected array $permissions = [
        ['name' => 'orders.index', 'description' => 'List orders', 'is_default' => true],
    ];

    protected array $roles = ['admin'];
}

::: tip Tip If an upgrade implements RollbackTableMigration, the package will automatically call rollbackTableMigration() when the data migration or post-data migration phase throws. :::

API

Commands

  • enso:upgrade {--manual} {--before-migration}
  • enso:upgrade:status

Core Services

  • LaravelEnso\Upgrade\Services\Finder
  • LaravelEnso\Upgrade\Services\Upgrade
  • LaravelEnso\Upgrade\Services\Database
  • LaravelEnso\Upgrade\Services\UpgradeStatus
  • LaravelEnso\Upgrade\Services\Structure

Execution Model

The current execution pipeline is split into three phases:

  • migrateTable()
  • migrateData()
  • migratePostDataMigration()

Only the migrateData() phase is wrapped in a database transaction.

migrateTable() and migratePostDataMigration() run outside the transaction boundary. If either the data migration or the post-data migration phase fails, and the upgrade implements RollbackTableMigration, the package calls rollbackTableMigration() to undo the table changes explicitly.

Contracts

Execution contracts:

  • Upgrade
  • MigratesTable
  • MigratesData
  • MigratesPostDataMigration
  • RollbackTableMigration
  • MigratesStructure

Execution modifiers:

  • Applicable
  • BeforeMigration
  • Prioritization
  • ShouldRunManually

Helpers

Database inspection helpers:

  • LaravelEnso\Upgrade\Helpers\Table
  • LaravelEnso\Upgrade\Helpers\Column

DBAL bridge:

  • LaravelEnso\Upgrade\Services\DBAL\Connection

Discovery Rules

The finder scans:

  • configured vendor folders from enso.upgrade.vendors
  • configured local folders from enso.upgrade.folders
  • Upgrades namespaces derived from each package's PSR-4 autoload root

Structure Upgrades

MigratesStructure upgrades are wrapped by LaravelEnso\Upgrade\Services\Structure, which:

  • creates missing permissions
  • assigns them to the default role
  • assigns non-default permissions only to explicitly listed roles
  • can run an additional post-data migration phase

Depends On

Required Enso packages:

External dependencies:

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

laravel-enso/upgrade 适用场景与选型建议

laravel-enso/upgrade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37.81k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 37.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 11
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-16