mbpcoder / laravel-api-versioning
Enable Api Versioning for Laravel
Installs: 156 672
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 3
Forks: 4
Open Issues: 2
Requires
- illuminate/routing: ^5|^6|^7|^8|^9|^10
Requires (Dev)
- orchestra/testbench: ^4.0|^8.0
- phpunit/phpunit: ^8.0|^10.0
This package is auto-updated.
Last update: 2024-11-03 18:06:37 UTC
README
This is a very simple package to support API versioning in Laravel 8,7,6,5. this package provide fallback API capability for Laravel.
Features
- If you have one API version it will automatically disable
- You can disable package in config files
- You can add countless API Versions in config file
- Does not affect routes except API
Let's Code!
If you call for /{version_number}/version every API have it is own route. If you call for /v2.1/hello-world it will try to call v2.1 and if it does not find a route will search v2 then if the version 2 also does not have the routes it will fallback to v1
// laravel route file Route::prefix('v2.1')->group(function () { Route::get('version', function () { return 'API v2.1'; }); }); Route::prefix('v2')->group(function () { Route::get('version', function () { return 'API v2'; }); }); Route::prefix('v1')->group(function () { Route::get('version', function () { return 'API v1'; }); Route::get('hello-world', function () { return 'Hello World!'; }); });
Installation
You can install the package via composer:
composer require mbpcoder/laravel-api-versioning
Usage
Publish config file
php artisan vendor:publish --provider="MbpCoder\ApiVersioning\ApiVersioningServiceProvider"
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.