Reputation: 11
I want to create api with link same api/v1/controller/action. But i can not config router. Please help me! Thanks you!
Upvotes: 1
Views: 632
Reputation: 9614
You use router scopes for that:
Router::scope('/api/v1', function ($routes) {
$routes->connect('/posts', ['controller' => 'Posts', 'action' => 'index']);
... // More routes here
});
Router::scope('/api/v2', function ($routes) {
$routes->connect('/posts', ['controller' => 'Posts', 'action' => 'index_v2']);
... // More routes here
});
Upvotes: 4