LaravelPackages.net
Acme Inc.
Toggle sidebar
hskrasek/laravel-sunset

12
1
1.0.0
About hskrasek/laravel-sunset

hskrasek/laravel-sunset is a Laravel package. It currently has 1 GitHub stars and 12 downloads on Packagist (latest version 1.0.0). Install it with composer require hskrasek/laravel-sunset. Discover more Laravel packages by hskrasek or browse all Laravel packages to compare alternatives.

Last updated

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.

Comments