Search code examples
windowsconsolemigrationcakedccakephp-2.5

CakePHP Error: Plugin Migrations could not be found


I installed CakeDC Migration Plugin and trying the command cake Migrations.migration generate, but got the error Error: Plugin Migrations could not be found.

The plugin installation path is app\Plugin\Migrations. I have added the path to the system environment variable D:\xampp\htdocs\myproj\app\Vendor\cakephp\cakephp\lib\Cake\Consolewhich is my CakePHP composer installed directory so that I could run the cake command globally.

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}

I changed the path to app\Vendor\bin, but still got the error:

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}

Again, I changed the path to app\Console, but the error is missing file of ShellDispatcher.php. The file exists in the cake global system path mentioned above, but not exist in 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

[Edit]

I have two plugins in app\Plugin:

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

I have CakePlugin::loadAll() in app\Config\bootstrap.php and I tried this:

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

The first line returns false while the second line returns true. Probably the Migration plugin could not be loaded properly.


Solution

  • By loading the plugin using CakePlugin::load() in bootstrap.php solved my problem, but I don't know why CakePlugin::loadAll() does not load it.

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