Hello there!
I’m trying to set up a version control for my api. Originally, I followed the bravo-kernel tutorial for setting up an API, but now I want to extend it with version control.
In routes.php I used prefix-routing to the namespace/directory “api”. In that dir, all controllers are stored. Now I want to change the routing in that way, that I call /api/v2/users/. This should map to the api namespace, to the same controllers but with a method-suffix _v2 like “index_v2”. So I have one controller for all API-Versions but with suffixed-methodnames. Does this make sense or should it completly separeted?
Therefore, I tried to have single connect-method in the routes.php api-scope like
Router::connect(’/:version/:controller’, [‘controller’ => ‘:controller’, ‘action’ => ‘:action_:version’, ‘prefix’ => ‘api’]);
but this doesn’t work. I don’t know how to set up the router for my use case. In general, routing is relatively new to me, so please help me.
Thanks in advance!