Implement date based versioning to Laravel Form Request and Resources for your API
palokankare/laravel-api-versions is a Laravel package for implement date based versioning to laravel form request and resources for your api.
It currently has 1 GitHub stars and 0 downloads on Packagist.
Install it with composer require palokankare/laravel-api-versions.
Discover more Laravel packages by palokankare
or browse all Laravel packages to compare alternatives.
Last updated
THIS PACKAGE IS STILL IN DEVELOPMENT
This Laravel package is a proof of concept and inspired of Stripe's blog post about API versioning
Rather than having large major API versions (v1, v2, v3...) the updates are small and named with the date they are released. This package tries to solve issue when it comes breaking change in Laravel From Requests (for example validation rules) and Laravel Resources.
API resources are written so that the structure they describe is what we’d expect back from the current version of the API. When we need to make a backwards-incompatible change we release new date based API version that will describe how to revert the change.
Example of how versions and changes are described.
return [
'2018-06-05' => [], // Latest version doesn't have any changes naturally. Doesn't have to be defined here.
'2018-05-28' => [
'App\Http\Resources\BookResource' => 'App\Http\Resources\Changes\UpdatePublishedDate',
'App\Http\Requests\StoreBook' => 'App\Http\Requests\Changes\\MakeAuthorNonMandatory',
],
'2018-05-26' => [
'App\Http\Resources\BookResource' => 'App\Http\Resources\Changes\AddAuthor',
'App\Http\Resources\FooResource' => 'App\Http\Resources\Changes\Bar',
],
];
Publish the config-file with:
php artisan vendor:publish --provider="Klopal\ApiVersions\ApiVersionsServiceProvider" --tag="config"
...
composer test
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.