A Laravel middleware to signal HTTP route deprecation (Deprecation, Sunset, Link headers)
heypongo/laravel-deprecation-middleware is a Laravel package for a laravel middleware to signal http route deprecation (deprecation, sunset, link headers).
It currently has 7 GitHub stars and 2 downloads on Packagist (latest version 1.0.0).
Install it with composer require heypongo/laravel-deprecation-middleware.
Discover more Laravel packages by heypongo
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel middleware to signal HTTP route deprecation using standardized HTTP headers (Deprecation RFC 8594, Sunset RFC 8594, Link RFC 8288).
Deprecation header to deprecated routesLink header with documentation URLSunset header for planned removalcomposer require heypongo/laravel-deprecation-middleware
The service provider is auto-discovered by Laravel. No manual registration is required.
Apply the middleware to your routes in routes/web.php or routes/api.php:
Route::get('/old-endpoint', function () {
// ...
})->middleware('deprecated');
You can specify deprecation date, documentation URL, and sunset date:
// Only deprecation date
Route::get('/old', fn() => ...)->middleware('deprecated:2024-06-01T00:00:00Z');
// Deprecation date and documentation URL
Route::get('/old', fn() => ...)->middleware('deprecated:2024-06-01T00:00:00Z,https://docs.example.com/deprecation');
// Deprecation date, documentation URL, and sunset date
Route::get('/old', fn() => ...)->middleware('deprecated:2024-06-01T00:00:00Z,https://docs.example.com/deprecation,2024-12-01T00:00:00Z');
// Only documentation URL and sunset date
Route::get('/old', fn() => ...)->middleware('deprecated,,https://docs.example.com/deprecation,2024-12-01T00:00:00Z');
Deprecation: Wed, 01 Jun 2024 00:00:00 GMT
Link: <https://docs.example.com/deprecation>; rel="deprecation"; type="text/html"
Sunset: Sun, 01 Dec 2024 00:00:00 GMT
You are encouraged to add tests using PHPUnit and Laravel's testing tools.
Install dev dependencies:
composer install
Run the tests:
vendor/bin/phpunit
MIT License. See LICENCE.