Reputation: 3852
I have a plugin named as PanelAdmin. It has Controller UsersController.php
and inside it there are different actions defined.
I have called the default controller within the plugin through this code
$routes->connect('/PanelAdmin', ['plugin' => 'PanelAdmin','controller' => 'default','action' => 'index']);
but cannot call other controller if i hit this url:
http://localhost/multi_shopping/PanelAdmin/Users/
One thing more i want to clear is i have to define routes for all controllers actions in routes.php. Please solve my issue. Thanks
Upvotes: 0
Views: 120
Reputation: 54821
In your plugin routes.php
make sure you are setting a fallback route.
routes.php
<?php
use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
Router::plugin(
'PanelAdmin',
['path' => '/PanelAdmin'],
function (RouteBuilder $routes) {
$routes->fallbacks(DashedRoute::class);
}
);
From the DashedRoute class:
/**
* This route class will transparently inflect the controller, action and plugin
* routing parameters, so that requesting `/my-plugin/my-controller/my-action`
* is parsed as `['plugin' => 'MyPlugin', 'controller' => 'MyController', 'action' => 'myAction']`
*/
Upvotes: 0