Looking to hire Laravel developers? Try LaraJobs

laravel-sunset maintained by hskrasek

Last update
2017/11/09 20:16 (dev-master)
License
Links
Downloads
12

Comments
comments powered by Disqus

Laravel Sunset

Build Status MIT License

Laravel Sunset allows you to deprecate URLs (API or otherwise).

The Sunset header is an in-development HTTP response header that is aiming to standardize how URLs are marked for deprecation. tl:dr; it looks a bit like this:

Sunset: Sat, 31 Dec 2018 23:59:59 GMT

This can be combined with a Link: <http://foo.com/something> rel="sunset" which can be anything that might help a developer know what is going on. Maybe link to your API documentation for the new resource, the OpenAPI/JSON Schema definitions, or even a blog post explaining the change.

Install

Via Composer

composer require hskrasek/laravel-sunset

Usage

Within your base controller, add the following:

<?php

namespace App\Http\Controllers;

use HSkrasek\Laravel\Sunset\SunsetsEndpoints;

class Controller {
    use SunsetsEndpoints;
}

Then when returning a response from your controller, do the following:

<?php

namespace App\Http\Controllers;

use HSkrasek\Laravel\Sunset\SunsetsEndpoints;

class APIController extends Controller {
    public function index()
    {
        // Other logic here
        return $this->sunsetsResponse(
            response()->json(['foo' => 'bar',]),
            '2017-12-31 23:59:59', // When this endpoint is being deprecated
            'http://example.com' // Optional link explaining the deprecation
        );
    }
}

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Bug reports and pull requests are welcome on GitHub at hskrasek/laravel-sunset. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.