为 ThinkPHP 8 提供 Phinx 数据迁移和 seed 命令。
5.0 尚未发布稳定 tag;试用开发分支时,桥接库会自动解析为稳定版 ^4.0:
composer require nhzex/think-phinx:5.0.x-dev需要 64 位 PHP 8.1+、Composer 2.1+。Symfony 7 需要 PHP 8.2+。升级前备份数据库并验证迁移与回滚,详见 5.0 升级说明。
php think migrate:create CreateUsers
php think migrate:run
php think migrate:status
php think migrate:rollback
php think seed:create UserSeeder
php think seed:run另有 migrate:breakpoint 管理断点、migrate:test 检查配置;各命令选项可通过 php think <命令> --help 查看。若升级后命令未出现,运行 php think service:discover。
在 config/phinx.php 中配置路径和迁移记录表,确保指定目录存在且可读:
<?php
return [
'paths' => [
'migrations' => [
'DbMigrations' => 'database/migrations',
],
'seeds' => [
'DbSeeds' => 'database/seeds'
]
],
'environments' => [
'default_migration_table' => '_phinxlog',
],
'version_order' => 'creation'
];