你如何在 CakePHP 2 中 运行 全局插件的 shell?

How do you run a global plugin's shell in CakePHP 2?

命令:

    C:\xampp\htdocs\site_name\app_name>php Console/cake.php -app app_name PluginName.foo

错误:

    Warning Error: include(C:\xampp\htdocs\site_name\app_name\Plugin\PluginName\Console\Command\FooShell.php): failed to open stream: No such file or directory in [C:\xampp\htdocs\site_name\lib\Cake\Core\App.php, line 547]

    Warning Error: include(): Failed opening 'C:\xampp\htdocs\site_name\app_name\Plugin\PluginName\Console\Command\FooShell.php' for inclusion (include_path='C:\xampp\htdocs\site_name\lib;.;C:\xampp\php\PEAR') in [C:\xampp\htdocs\site_name\lib\Cake\Core\App.php, line 547]

    Error: Shell class FooShell could not be found.
    #0 C:\xampp\htdocs\site_name\lib\Cake\Console\ShellDispatcher.php(200): ShellDispatcher->_getShell('PluginName.back...')
    #1 C:\xampp\htdocs\site_name\lib\Cake\Console\ShellDispatcher.php(66): ShellDispatcher->dispatch()
    #2 C:\xampp\htdocs\site_name\app_name\Console\cake.php(33): ShellDispatcher::run(Array)
    #3 {main}

出于某种原因,CakePHP 可以在 ROOT/plugins 中为实际网页提供此插件,但会在控制台中抛出错误。

shell docs or the plugin docs explicitly says that there's anything different about using plugins in ROOT/plugins, but discussion of how that directory is used is conspicuously absent from the plugin and folder structure docs 中没有内容。 (我假设是因为它暗示你应该以相同的方式实现插件,不管它们在哪个目录中。)

我做错了吗?

当它在 ROOT/plugins 目录中时,您需要像这样在 ROOT/lib/Cake/bootstrap.php

中加载它
App::build(array('Plugin' => array(CAKE . DS . 'plugins' . DS)));
CakePlugin::load('<plugin-name>');