Add Versioning to API Routes in Laravel


1 min read

  1. Create a folder named api in routes
  2. Copy routes\api.php into the api folder
  3. Rename api.php to v1.php
  4. Change below app\Providers\RouteServiceProvers.php
     // example route will be /api/v1/users
     Route::prefix('api/v1') // add a version number
         ->group(base_path('routes/api/v1.php')); // update the path to the api routes