A beautiful command-line database migration tool for any PHP project. Laravel-style migrations without the framework complexity.
β¨ 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
Install Schema Migrator globally via Composer:
composer global require dconco/schema-migratorMake sure your global Composer bin directory is in your PATH:
# Add to your ~/.bashrc or ~/.zshrc
export PATH="$PATH:$HOME/.composer/vendor/bin"Navigate to your PHP project and initialize Schema Migrator:
cd /path/to/your/project
schema-migrator initThis will:
- Create a
schema-migrator.ymlconfiguration file - Create a
database/migrationsdirectory - Prompt you for database connection details
schema-migrator make:migration CreateUsersTableEdit 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');
}
};schema-migrator migrateschema-migrator initCreates configuration and migrations directory in current project.
schema-migrator make:migration CreatePostsTable
schema-migrator make:migration AddEmailToUsersTableCreates a new migration file with timestamp.
schema-migrator migrateExecutes all pending migrations.
schema-migrator migrate:statusShows which migrations have been executed and which are pending.
schema-migrator migrate:rollback
schema-migrator migrate:rollback --steps=3Rolls back the last batch of migrations (or specified number of batches).
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/migrationsyour-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
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']);
});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 migrateEach project maintains its own configuration and migration state.
- PHP 8.1 or higher
- PDO extension for your database
- Composer (for global installation)
The MIT License (MIT). Please see License File for more information.
Contributions are welcome! Please feel free to submit a Pull Request.
Now you have Laravel-style migrations in any PHP project! π