macwinnie / wp-db-phinx-helper
WordPress 插件辅助工具,使其能够使用 [Phinx](https://phinx.org/) 进行数据库迁移
0.1.5
2024-06-09 21:43 UTC
Requires
- composer/composer: ^2.7
- robmorgan/phinx: ^0.16.1
README
此助手允许您使用 Phinx 定义数据库迁移。放置的配置文件 phinx.php
将使用 WordPress 配置的数据库。
要使 Phinx 能够工作,请在插件目录中在 bash 命令行上运行
cp vendor/macwinnie/wp-db-phinx-helper/files/phinx.php ./
还可以通过您的插件类扩展 Macwinnie\WpDbPhinxHelper\DBUtilisator
类
class MyPlugin extends DBUtilisator { public static function plugin_activation_method () { parent::plugin_activation_method(); # ensures Phinx config placed and migrations run on install / activation / update } public static function plugin_uninstall_method () { parent::plugin_uninstall_method(); # ensures Phinx migrations rolled back in Database on Plugin uninstall } }
静态函数 static::basePath()
可以用来获取您的插件在 Web 服务器上的绝对路径 - 同时也会检查 Phinx 配置文件是否存在于您的插件基本目录中。