I would like to place some of my controller classes in a subfolder (src/Controller/Admin/). Does anyone know how this can be made in CakePhp3?
How to place controller in subfolders in CakePhp3?
Asked Answered
Check the routing section in the cookbook http://book.cakephp.org/3.0/en/development/routing.html#prefix-routing
I want to separate my controller and place it in sub directory, Is it possible? –
Bruner
Sounds like you’re looking for Routing Prefixes
https://book.cakephp.org/3.0/en/development/routing.html#prefix-routing
This is for people that also want to add subfolders inside an already prefix subfolder.
This way you can have this structure:
src/Controller/Api/V1/BookingsController.php
BookingsController:
<?php
namespace App\Controller\Api\V1;
use App\Controller\AppController;
/**
* V1
*/
class BookingsController extends AppController
{
public function list()
{
die('here we are');
}
}
routes.php
Router::prefix('api/v1', function (RouteBuilder $routes) {
$routes->extensions(['json']);
$routes->fallbacks(DashedRoute::class);
});
and what will be the restful uri ? –
Sandie
© 2022 - 2024 — McMap. All rights reserved.