Issue
I bake a plugin and created a controller manually it is working on my local server but, when I move the plugin through the and hit the url cake saying the controller is missing at plugin controller location i.e. plugins/TourPackages/src/Controller/TourPackagesController.php the file is exist in the location, but it still saying controller is missing. i'm attaching the screen shot of it. I am facing this issue for other plugin that I have created.
Solution
I guess it was issue of routing I have tried multiple combinations of URL for the plugin name and the controller name.
What was done in View (.ctp)
<?php echo $this->Html->link('<h3>Package Name</h3>', ['controller'=>'TourPackages', 'plugin'=>'TourPackages', 'action'=>'sample'], ['title'=>'Package Name', 'class'=>'', 'escape'=>false]);?>
which generate html like <a href="http://demos.cybershines.com/naturessprout/tour-packages/tour-packages/sample" title="Package Name" class=""><h3>Package Name</h3></a>
In My plugin router the routing code was
Router::plugin(
'TourPackages',
['path' => '/tour-packages'],
function (RouteBuilder $routes) {
$routes->fallbacks(DashedRoute::class);
}
);
This I changed to
Router::plugin(
'TourPackages',
['path' => '/tour-packages'],
function (RouteBuilder $routes) {
$routes->get('/tour-packages/tour-packages/*', ['controller' => 'TourPackages']);
$routes->fallbacks(DashedRoute::class);
}
);
it taking the "path" /tour-packages for plugin but the controller as "TourPackages"
so when I hit http://demos.cybershines.com/naturessprout/tour-packages/TourPackages/sample cake takes me to the correct location and view. So, I modified the routing code by adding
$routes->get('/tour-packages/tour-packages/*', ['controller' => 'TourPackages']);
in routing.php and tell cake to execute the TourPackagesController for tour-packages.
Answered By - Parag Chaure

0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.