致命错误:未捕获错误:调用未定义的方法Phinx \ Db \ Adapter \ MysqlAdapter :: getCakeConnection()

时间:2018-05-09 10:13:39

标签: php cakephp

我遇到了Phinx迁移的问题, 目前我正在处理表关系,我必须使用Phinx来创建外键,但是当我运行命令phinx migrate时,会发生错误。

Error: Call to undefined method Phinx\Db\Adapter\MysqlAdapter::getCakeConnection() in \cms\vendor\cakephp\migrations\src\Table.php on line 79

我无法找到任何线索。

这是详细错误:

 call C:\path\development\cms\vendor\robmorgan\phinx\bin\phinx.bat migrate 
 Phinx by Rob Morgan - https://phinx.org. 0.8.1

 using config file .\phinx.yml using config parser yaml using migration
 paths
  - C:\path\development\cms\config\db\migrations
 using seed paths
  - C:\path\development\cms\config\db\seeds warning no environment specified, defaulting to: development using
 adapter mysql using database app_db

  == 20180509032904 CreateDevices: migrating

 Fatal error: Uncaught Error: Call to undefined method
 Phinx\Db\Adapter\MysqlAdapter::getCakeConnection() in
 C:\path\development\cms\vendor\cakephp\migrations\src\Table.php
 on line 79

 Error: Call to undefined method
 Phinx\Db\Adapter\MysqlAdapter::getCakeConnection() in
 C:\path\development\cms\vendor\cakephp\migrations\src\Table.php
 on line 79

 Call Stack:
     0.4312     413768   1. {main}() C:\path\development\cms\vendor\robmorgan\phinx\bin\phinx:0
     0.4468    2004152   2. Phinx\Console\PhinxApplication->run() C:\path\development\cms\vendor\robmorgan\phinx\bin\phinx:28
     0.5716    2236128   3. Phinx\Console\PhinxApplication->doRun() C:\path\development\cms\vendor\symfony\console\Application.php:148
     0.5716    2236176   4. Phinx\Console\PhinxApplication->doRun() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Console\PhinxApplication.php:83
     0.5716    2236176   5. Phinx\Console\PhinxApplication->doRunCommand()
 C:\path\development\cms\vendor\symfony\console\Application.php:248
     0.5716    2236176   6. Phinx\Console\Command\Migrate->run() C:\path\development\cms\vendor\symfony\console\Application.php:946
     0.5716    2240328   7. Phinx\Console\Command\Migrate->execute() C:\path\development\cms\vendor\symfony\console\Command\Command.php:252
     0.6028    2829928   8. Phinx\Migration\Manager->migrate() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Console\Command\Migrate.php:113
     1.6454    3406784   9. Phinx\Migration\Manager->executeMigration() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Migration\Manager.php:342
     1.6454    3406784  10. Phinx\Migration\Manager\Environment-executeMigration()
 C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Migration\Manager.php:366
     1.6454    3406784  11. CreateDevices->change() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Migration\Manager\Environment.php:122
     1.6454    3470712  12. Migrations\Table->create() C:\path\development\cms\config\db\migrations\20180509032904_create_devices.php:55

1 个答案:

答案 0 :(得分:0)

我找到原因,在将CakePHP的默认迁移文件移动到Phinx之前,但我忘了更改使用命名空间来使用Phinx \ Migration \ AbstractMigration;。现在Phinx可以正常运行了。感谢@Nico Haase