Reputation: 3817
I am having this error which does not seem to make sense. I am using this plugin: https://github.com/hashmode/cakephp-tinymce-elfinder. I am in need of creating and admin route. However, even though CakePHP sees the plugin, it does not see the Controller within it. I don't see what I am doing wrong.
This is my route for /admin/elfinder
:
Router::prefix('admin', function ($routes) {
$routes->connect('/elfinder', ['plugin' => 'CakephpTinymceElfinder', 'controller' => 'Elfinders', 'action' => 'elfinder']);
});
This is the controller/action I am trying to access
But I get the following error:
2018-06-01 15:20:33 Error: [Cake\Routing\Exception\MissingControllerException] Controller class Elfinders could not be found.
Request URL: /admin/elfinder
It is definitely finding the Plugin. Why can't CakePHP find the controller?
Upvotes: 0
Views: 2433
Reputation: 61
According to the official CookBook you need to configure your prefixed routes in the following way. Hope this helps.
Router::plugin('YourPlugin', function ($routes) {
$routes->prefix('admin', function ($routes) {
$routes->connect('/:controller');
});
});
https://book.cakephp.org/3.0/en/development/routing.html#prefix-routing
Some time ago I wrote a plugin for my personal needs. I needed to bind its controllers to the /shop
and /shop/api
URLs. I managed to do it like this
Router::scope('/shop',['plugin'=>'MyPlugin'] ,function (RouteBuilder $routes) {
$routes->prefix('api', function($routes) {
$routes->extensions(['json']);
$routes->connect('/:controller');
$routes->resources('Categories');
$routes->resources('Products');
$routes->resources('Prices');
$routes->resources('Pricetypes');
});
$routes->connect('/:controller');
$routes->fallbacks(DashedRoute::class);
});
Upvotes: 1