我安装了CakeDC Migration Plugin并尝试了cake Migrations.migration generate
命令,但收到错误错误:无法找到插件迁移。
插件安装路径为app\Plugin\Migrations
。我已经添加了系统环境变量D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Console
的路径,这是我的CakePHP编写器安装目录,因此我可以全局运行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
。可能无法正确加载Migration插件。
答案 0 :(得分:0)
在bootstrap.php中使用CakePlugin::load()
加载插件解决了我的问题,但我不知道为什么CakePlugin::loadAll()
无法加载它。
CakePlugin::loadAll();
CakePlugin::load('Migrations');
答案 1 :(得分:0)
CakePlugin :: loadAll()加载所有插件。 所以我猜Cache就是这个原因。 如果删除缓存,CakePlugin :: loadAll()可以加载所有插件。