I am new to Laravel (4 and 5) and recently I am working on a RESTful API. In order to allow multiple version of the API, I am using URL to determine the version.
I read follow this post and it seem most people following this approach: How to organize different versioned REST API controllers in Laravel 4?
Folders structures:
/app
/controllers
/Api
/v1
/UserController.php
/v2
/UserController.php
And in UserController.php files I set the namespace accordingly:
namespace Api\v1;
or
namespace Api\v2;
and in routes:
Route::group(['prefix' => 'api/v1'], function () {
Route::get('user', 'Api\v1\UserController@index');
Route::get('user/{id}', 'Api\v1\UserController@show');
});
Route::group(['prefix' => 'api/v2'], function () {
Route::get('user', 'Api\v2\UserController@index');
Route::get('user/{id}', 'Api\v2\UserController@show');
});
URL will be simple http://..../api/v1 for version 1 and http://..../api/v2 for version. This is straight forward.
My questions is: What if I am building minor upgrade of api, say v1.1 , how do I organize my folder structure? My thought was this and it should be still fine as dot is valid name of folders?
/app
/controllers
/Api
/v1
/UserController.php
/v1.1
/UserController.php
/v1.2
/UserController.php
/v2
/UserController.php
Also, how should I write the namespace? This is no namespace like this
namespace Api\v1.1;
Is there naming convention I can refer to for using "dot" ?
Note: I do not want to call it as version v2 because this is not a major upgrade.