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.
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.ymlconfiguration file - Create a
database/migrationsdirectory - 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dconco/schema-migrator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
PHP module for MySql database
Slim starter / Slim skeleton package to boost your development with Slim framework
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-08