PluginName/Console/Command/FooShell.php
的shell。CakePlugin::load('PluginName');
中通过bootstrap.php
加载此插件。ROOT/app_name/Plugin
时,我运行PluginName.foo
, shell正常运行。ROOT/plugins
并且我运行相同的命令时,我收到错误:命令:
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}
出于某种原因,当这个插件服务于实际网页时,此插件位于ROOT/plugins
,但CakePHP很好,但在控制台中抛出错误。
shell docs或plugin docs中的任何内容都没有明确说明在ROOT/plugins
中使用插件有什么不同,但是如何使用该目录的讨论显然不存在插件和folder structure docs。 (我假设,因为它暗示你应该以相同的方式实现插件,无论他们在哪个目录中。)
我这样做错了吗?
答案 0 :(得分:1)
当它位于ROOT/plugins
目录中时,您需要在ROOT/lib/Cake/bootstrap.php
App::build(array('Plugin' => array(CAKE . DS . 'plugins' . DS)));
CakePlugin::load('<plugin-name>');