Reputation: 1707
I'm trying to config a RESTful API resources mapping in CakePHP3. I followed some tuts but can't make it works.
I'm using 'prefix' route to map /api/v2/:resource
with my sub-folders inside Controllers folder.
My file structure:
And this is my routing config
Router::prefix('api/v2', function ($routes) {
$routes->resources('Users');
// $routes->get('users', ['controller' => 'Users', 'action' => 'view']);
// $routes->post('users', ['controller' => 'Users', 'action' => 'create']);
// $routes->post('token', ['controller' => 'Users', 'action' => 'token']);
// $routes->fallbacks(DashedRoute::class);
});
As I read in the tuts i mention before, this should works, but i get a Missing Contoller Exception for ApiController.
If I uncomment the last line, enabling fallbacks
it works fine, but it's not matching the Controller Methods with the HTTP method GET, POST, DELETE, PUT as CakePHP3 documentation mention.
Any ideas? My Cake version in 3.5.8
Thanks!!
EDIT: using bin/cake routes
it's seems like the routes are fine. I'm using Postman to make request with differents HTTP methods to test this.
EDIT 2: I tried with another prefix Foo
to avoid the V2 case sensitive issue, and well, this is extrage, the routes seems to be fine, but cake are not matching any of them..
Upvotes: 1
Views: 794