rafaelmiano/phpspa-migrate
Composer 安装命令:
composer require rafaelmiano/phpspa-migrate
包简介
A simple and elegant database migration system for PHP applications
README 文档
README
A simple and elegant database migration system for PHP applications.
Installation
composer require rafaelmiano/phpspa-migrate
Configuration
Create a .env file in your project root with database configuration:
DB_HOST=localhost DB_DATABASE=your_database DB_USERNAME=root DB_PASSWORD=
Usage
You can use the migration tool through vendor/bin:
php vendor/bin/migrate create users_table
Creating Migrations
This will create a new migration file in database/migrations with a timestamp prefix.
Example:
php vendor/bin/migrate create users_table
This will create a new migration file in database/migrations with a timestamp prefix.
Writing Migrations
<?php use RafaelMiano\PhpSpaMigrate\Migration\Migration; return new class($connection) extends Migration { public function up() { $this->createTable('users', function($table) { $table->id(); $table->string('username')->unique(); $table->string('email'); $table->string('password'); $table->timestamps(); }); } public function down() { $this->dropTable('users'); } };
Available Schema Methods
id()- Add auto-incrementing IDstring(name, length = 255)- Add VARCHAR columninteger(name)- Add INT columntext(name)- Add TEXT columntimestamp(name)- Add TIMESTAMP columntimestamps()- Add created_at and updated_at columnsunique()- Make column uniquenullable()- Make column nullableforeignKey(column)- Add foreign keyreferences(table.column)- Reference a foreign key
Running Migrations
php vendor/bin/migrate run # Run pending migrations php vendor/bin/migrate fresh # Drop all tables and run migrations
Rolling Back Migrations
php vendor/bin/migrate rollback # Rollback last batch of migrations
Other Commands
php vendor/bin/migrate help # Show all available commands php vendor/bin/migrate status # Show migration status
Fresh Migrations
The fresh command provides a clean slate by dropping all tables and running migrations again:
php vendor/bin/migrate fresh
This will:
- Show a confirmation prompt
- Drop all existing tables
- Recreate the migrations table
- Run all migrations from scratch
Features
- Interactive database creation
- Batch-based migrations
- Simple and intuitive schema builder
- Environment configuration support
- Rollback capability
- Pretty console output
- Error handling and user feedback
Contributing
Feel free to submit pull requests or create issues for bugs and feature requests.
License
This package is open-source software licensed under the MIT license.
rafaelmiano/phpspa-migrate 适用场景与选型建议
rafaelmiano/phpspa-migrate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 rafaelmiano/phpspa-migrate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rafaelmiano/phpspa-migrate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-10