Sergio
Sergio

Reputation: 2469

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

Link my problem: https://github.com/cakephp/cakephp/issues/10966

What you did

Created by console plugin example.

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

//change ok bootstrap.php

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

Router Plugin:

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

Print: DebugKit

enter image description here

Print: My Tree folder in Plugins

enter image description here

What happened

Error in browser: "An Internal Server Error Occurred"

Out file 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}

What you expected to happen

Load ok my class my plugin subfolder /app/plugins/EOM/Shop/ or /app/plugins/MyCompany/Shop/

Upvotes: 0

Views: 4246

Answers (1)

Sergio
Sergio

Reputation: 2469

Detect the problem, the solution is simple to be careful when creating the plugin and the controllers. Because it's easy because I always have the uppercase name at the beginning.

Example for gener Fix:

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

Example for no error:

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

And no problema load class change bootstrap.php

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

OR Execute in console, not add change in bootstrap.php ['autoload' => true, ...]:

php composer.phar dumpautoload

Upvotes: 1

Related Questions