【问题标题】:CakePHP Error: Plugin Migrations could not be foundCakePHP 错误:找不到插件迁移
【发布时间】:2014-09-23 07:21:16
【问题描述】:

我安装了CakeDC Migration Plugin 并尝试了命令cake Migrations.migration generate,但得到了错误错误:找不到插件迁移

插件安装路径为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

我在app\Config\bootstrap.php 中有CakePlugin::loadAll(),我试过这个:

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

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

【问题讨论】:

    标签: windows console migration cakedc cakephp-2.5


    【解决方案1】:

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

    CakePlugin::loadAll();
    CakePlugin::load('Migrations');
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-02
        • 1970-01-01
        • 2021-02-19
        • 1970-01-01
        • 1970-01-01
        • 2021-07-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多