0

我安装了CakeDC Migration Plugin并尝试了命令cake Migrations.migration generate,但收到错误Error: Plugin Migrations could not be found

插件安装路径为app\Plugin\Migrations. 我已经添加了系统环境变量的路径,D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console这是我的 CakePHP composer 安装目录,以便我可以cake全局运行命令。

D:\xampp\htdocs\myproj\app>cake

Welcome to CakePHP v2.5.4 Console
---------------------------------------------------------------
App : app
Path: D:\xampp\htdocs\myproj\app\
---------------------------------------------------------------
Current Paths:

 -app: app
 -working: D:\xampp\htdocs\myproj\app
 -root: D:\xampp\htdocs\myproj
 -core: D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib

Changing Paths:

Your working path should be the same as your application path. To change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp

Available Shells:
[CORE] acl, api, bake, command_list, completion, console, i18n, schema, server,test, testsuite, upgrade
[app] demo, send_mail_at_call_time, update_num_order_cache

To run an app or core command, type cake shell_name [args]
To run a plugin command, type cake Plugin.shell_name [args]
To get help on a specific command, type cake shell_name --help

D:\xampp\htdocs\myproj\app>cake Migrations.migration generate

Error: Plugin Migrations could not be found.
#0 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Core\App.php(227):CakePlugin::path('Migrations')
#1 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Core\App.php(549):App::path('Console/Command', 'Migrations')
#2 [internal function]: App::load('MigrationShell')
#3 [internal function]: spl_autoload_call('MigrationShell')
#4 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\ShellDispatcher.php(249): class_exists('MigrationShell')
#5 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\ShellDispatcher.php(200): ShellDispatcher->_getShell('Migrations.migr...')
#6 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\ShellDispatcher.php(66): ShellDispatcher->dispatch()
#7 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\cake.php(54): ShellDispatcher::run(Array)
#8 {main}

我将路径更改为app\Vendor\bin,但仍然出现错误:

D:\xampp\htdocs\myproj\app\Vendor\bin>cake Migrations.migration generate

Error: Plugin Migrations could not be found.
#0 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Core\App.php(227):CakePlugin::path('Migrations')
#1 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Core\App.php(549):App::path('Console/Command', 'Migrations')
#2 [internal function]: App::load('MigrationShell')
#3 [internal function]: spl_autoload_call('MigrationShell')
#4 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\ShellDispatcher.php(249): class_exists('MigrationShell')
#5 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\ShellDispatcher.php(200): ShellDispatcher->_getShell('Migrations.migr...')
#6 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\ShellDispatcher.php(66): ShellDispatcher->dispatch()
#7 D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console\cake.php(54): ShellDispatcher::run(Array)
#8 {main}

同样,我将路径更改为app\Console,但错误是缺少 ShellDispatcher.php 文件。该文件存在于上述cake全局系统路径中,但不存在于app\Console.

D:\xampp\htdocs\myproj\app>cd Console

D:\xampp\htdocs\myproj\app\Console>cake Migrations.migration generate

Warning: include(Cake\Console\ShellDispatcher.php): failed to open stream: No su
ch file or directory in D:\xampp\htdocs\myproj\app\Console\cake.php on line 28

Warning: include(): Failed opening 'Cake\Console\ShellDispatcher.php' for inclusion (include_path='D:\xampp\htdocs\myproj\lib;.;D:\xampp\php\PEAR') in D:\xampp\htdocs\myproj\app\Console\cake.php on line 28

Fatal error: Could not locate CakePHP core files. in D:\xampp\htdocs\myproj\app\Console\cake.php on line 29

[编辑]

我有两个插件app\Plugin

app\
 |--Plugin\
    |-- Migrations
    |-- Qdmail

我已经CakePlugin::loadAll()进去了app\Config\bootstrap.php,我试过这个:

CakePlugin::loadAll();
var_dump(CakePlugin::loaded('Migrations'));
var_dump(CakePlugin::loaded('Qdmail'));

第一行返回false,第二行返回true。可能无法正确加载迁移插件。

4

2 回答 2

0

通过CakePlugin::load()在 bootstrap.php 中使用加载插件解决了我的问题,但我不知道为什么CakePlugin::loadAll()不加载它。

CakePlugin::loadAll();
CakePlugin::load('Migrations');
于 2014-09-24T05:01:36.750 回答
0

CakePlugin::loadAll() 加载所有插件。所以我猜缓存是这个原因。如果您删除缓存,CakePlugin::loadAll() 可以加载所有插件。

于 2015-06-30T07:37:44.190 回答