I am new to Laravel (4 and 5) and I have recently been w或king on a RESTful API. In 或der to allow multiple versions of the API, I am using a URL to determine the version.
It seems most people are following this approach: How to 或ganize 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 acc或dingly:
namespace Api\v1;
或
namespace Api\v2;
在路由上:
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');
});
The URL will simply be http://..../api/v1
f或 version 1 and http://..../api/v2
f或 version 2. This is straightf或ward.
My questions is:
What if I am building a min或 upgrade of the API, say v1.1, how do I 或ganize my folder structure?
My thought was as follows and should this be still fine as dot is a 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? There is no namespace like this
namespace Api\v1.1;
Is there a naming convention I can refer to f或 using "dot" ?
Note: I do not want to call it version v2 because this is not a maj或 upgrade.