Reputation: 4367
I'm studying Laravel REST, but maybe this does not limit itself to Laravel only.
Reading through articles and questions like Laravel RESTful API versioning Design or How to organize different versioned REST API controllers in Laravel 4? (and a lot others) you get the concept that it's very important to version a API when building one.
But it seems to me that it may be a lot troublesome to manage different versions of your API using the separation of folders
/app
/controllers
/Api
/v1
/UserController.php
/v2
/UserController.php
Looking from a near future, I can easily imagine having 30 files at v1 and 40 files at v2, for instance where about 20~25 files might be identical. Doesnt' this cause more troubles than solution?
Upvotes: 3
Views: 1322
Reputation: 3947
If the changes are large enough, they will probably warrant a new Controller. But if not, you could pass the version number to the Controller instance, and route to the same controller. Then use that number to change behavior.
Upvotes: 1