Api

Versioning

Versioning and breaking changes.

Versioning your API from the beginning is crucial for long-term maintainability. It allows you to introduce breaking changes without affecting existing client applications.

  • URL Prefixing: The most common method is to prefix your API routes with a version number (e.g. /api/v1/photos.php).
routes/web.php
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->group(function () {
    Route::apiResource('photos', PhotoController::class);
});
Copyright © 2026