CakePHP 3 错误生成器插件:[Cake\Core\Exception\MissingPluginException] 找不到插件

CakePHP 3 Error generator Plugin : [Cake\Core\Exception\MissingPluginException] Plugin could not be found

Link我的问题:https://github.com/cakephp/cakephp/issues/10966

你做了什么

由控制台插件示例创建。

.\bin\cake bake plugin EOM/shop
.\bin\cake bake controller hola -p EOM/shop

//改好bootstrap.php

Plugin::load('EOM/shop', ['bootstrap' => false, 'routes' => true]);

路由器插件:

Router::plugin(
    'EOM/shop',
    ['path' => '/e-o-m/shop'],
    function (RouteBuilder $routes) {
        $routes->fallbacks(DashedRoute::class);
    }
);

打印:DebugKit

打印:插件中的 My Tree 文件夹

发生了什么事

浏览器错误:"An Internal Server Error Occurred"

输出文件error.log

2017-07-30 21:33:13 Error: [Cake\Core\Exception\MissingPluginException] Plugin EOM/Shop could not be found.
Exception Attributes: array (
  'plugin' => 'EOM/Shop',
)
Request URL: /e-o-m/shop/hola
Stack Trace:
#0 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Core\App.php(190): Cake\Core\Plugin::classPath('EOM/Shop')
#1 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\View\View.php(1269): Cake\Core\App::path('Template', 'EOM/Shop')
#2 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\View\View.php(1087): Cake\View\View->_paths('EOM/Shop')
#3 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\View\View.php(592): Cake\View\View->_getViewFileName('Error\error500')
#4 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Error\ExceptionRenderer.php(364): Cake\View\View->render('error500', 'error')
#5 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Error\ExceptionRenderer.php(341): Cake\Error\ExceptionRenderer->_outputMessageSafe('error500')
#6 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Error\ExceptionRenderer.php(200): Cake\Error\ExceptionRenderer->_outputMessage('missingControll...')
#7 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Error\Middleware\ErrorHandlerMiddleware.php(110): Cake\Error\ExceptionRenderer->render()
#8 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Error\Middleware\ErrorHandlerMiddleware.php(94): Cake\Error\Middleware\ErrorHandlerMiddleware->handleException(Object(Cake\Routing\Exception\MissingControllerException), Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#9 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner))
#10 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Http\Runner.php(51): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#11 D:\www\app.aptitud.local\www\vendor\cakephp\cakephp\src\Http\Server.php(80): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(Cake\Http\Response))
#12 D:\www\app.aptitud.local\www\webroot\index.php(37): Cake\Http\Server->run()
#13 {main}

你预期会发生什么

加载好我的 class 我的插件子文件夹 /app/plugins/EOM/Shop//app/plugins/MyCompany/Shop/

检测到问题, 创建插件和控制器时,解决方案很简单,需要小心。因为这很容易,因为我总是以大写开头。

生成修复示例:

.\bin\cake bake plugin EOM/shop
.\bin\cake bake controller hola -p EOM/shop

无错误示例:

.\bin\cake bake plugin EOM/Shop
.\bin\cake bake controller Hola -p EOM/Shop

没问题加载 class 更改 bootstrap.php

Plugin::load('EOM/Shop', ['autoload' => true, 'bootstrap' => false, 'routes' => true]);

或在控制台中执行,不在 bootstrap.php 中添加更改 ['autoload' => true, ...]:

php composer.phar dumpautoload