承接 dconco/schema-migrator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dconco/schema-migrator

Composer 安装命令:

composer require dconco/schema-migrator

包简介

A beautiful command-line database migration tool for any PHP project. Laravel-style migrations without the framework.

README 文档

README

A beautiful command-line database migration tool for any PHP project. Laravel-style migrations without the framework complexity.

Software License

Features

Beautiful CLI Interface - Powered by Symfony Console with colored output and interactive commands
🚀 Global Installation - Install once, use anywhere in any PHP project
🔧 Zero Dependencies - No need to install Laravel or any framework in your projects
📁 Project-Based Config - Each project maintains its own configuration and migrations
🗄️ Multi-Database Support - MySQL, PostgreSQL, SQLite, and SQL Server
Laravel-Compatible - Uses Laravel's proven migration syntax and features

Global Installation

Install Schema Migrator globally via Composer:

composer global require dconco/schema-migrator

Make sure your global Composer bin directory is in your PATH:

# Add to your ~/.bashrc or ~/.zshrc
export PATH="$PATH:$HOME/.composer/vendor/bin"

Quick Start

1. Initialize in Your Project

Navigate to your PHP project and initialize Schema Migrator:

cd /path/to/your/project
schema-migrator init

This will:

  • Create a schema-migrator.yml configuration file
  • Create a database/migrations directory
  • Prompt you for database connection details

2. Create Your First Migration

schema-migrator make:migration CreateUsersTable

3. Edit the Migration

Edit the generated file in database/migrations/:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Capsule\Manager as Capsule;

return new class extends Migration {
    public function up(): void
    {
        Capsule::schema()->create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Capsule::schema()->dropIfExists('users');
    }
};

4. Run Migrations

schema-migrator migrate

Commands

Initialize Project

schema-migrator init

Creates configuration and migrations directory in current project.

Create Migration

schema-migrator make:migration CreatePostsTable
schema-migrator make:migration AddEmailToUsersTable

Creates a new migration file with timestamp.

Run Migrations

schema-migrator migrate

Executes all pending migrations.

Check Status

schema-migrator migrate:status

Shows which migrations have been executed and which are pending.

Rollback Migrations

schema-migrator migrate:rollback
schema-migrator migrate:rollback --steps=3

Rolls back the last batch of migrations (or specified number of batches).

Configuration

The schema-migrator.yml file contains your project's configuration:

database:
  driver: mysql          # mysql, pgsql, sqlite, sqlsrv
  host: 127.0.0.1
  port: 3306
  database: your_database
  username: your_username
  password: your_password
  charset: utf8mb4
  collation: utf8mb4_unicode_ci
  prefix: ''
migrations:
  table: migrations
  path: database/migrations

Usage Examples

Project Structure

your-project/
├── schema-migrator.yml
├── database/
│   └── migrations/
│       ├── 2025_01_01_000000_create_users.php
│       ├── 2025_01_01_000001_create_posts.php
│       └── 2025_01_01_000002_add_category_to_posts.php
├── src/
└── composer.json

Migration Examples

Create a table:

Capsule::schema()->create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->text('content');
    $table->foreignId('user_id')->constrained();
    $table->timestamps();
});

Add columns:

Capsule::schema()->table('users', function (Blueprint $table) {
    $table->string('phone')->nullable();
    $table->boolean('is_active')->default(true);
});

Create indexes:

Capsule::schema()->table('posts', function (Blueprint $table) {
    $table->index('title');
    $table->index(['user_id', 'created_at']);
});

Multiple Projects

Schema Migrator works per-project. You can use it in multiple projects simultaneously:

cd /project-a
schema-migrator init      # Configure for project A
schema-migrator migrate

cd /project-b  
schema-migrator init      # Configure for project B  
schema-migrator migrate

Each project maintains its own configuration and migration state.

Requirements

  • PHP 8.1 or higher
  • PDO extension for your database
  • Composer (for global installation)

License

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

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Now you have Laravel-style migrations in any PHP project! 🎉

dconco/schema-migrator 适用场景与选型建议

dconco/schema-migrator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 7, 最近一次更新时间为 2025 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 dconco/schema-migrator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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