API Versioning
Version your API to allow breaking changes without breaking existing clients. Common strategies: URI prefix (/v1/), header, or query parameter.
Version your API to allow breaking changes without breaking existing clients. Common strategies: URI prefix (/v1/), header, or query parameter.
// routes/api.php — URI versioning
Route::prefix("v1")->namespace("Api\V1")->group(base_path("routes/api_v1.php"));
Route::prefix("v2")->namespace("Api\V2")->group(base_path("routes/api_v2.php"));
// app/Http/Controllers/Api/V1/UserController.php
// app/Http/Controllers/Api/V2/UserController.php
// V2 returns extra fields without breaking V1 consumers
Never remove or rename fields in a versioned API — add a new version instead.