2017 © Pedro Peláez
 

library laravel-multiformat

Multiformat Endpoints in Laravel

image

m1guelpf/laravel-multiformat

Multiformat Endpoints in Laravel

  • Saturday, February 17, 2018
  • by m1guelpf
  • Repository
  • 2 Watchers
  • 24 Stars
  • 901 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 52 % Grown

The README.md

Multiformat Endpoints in Laravel

Latest Version on Packagist Total Downloads, (*1)

Installation

You can install the package via composer:, (*2)

composer require m1guelpf/laravel-multiformat

Usage

``` php <?php, (*3)

/** * Mark a route as 'multiformat' to allow different extensions (html, json, xml, etc.) * * This route will match all of these requests: * /podcasts/4 * /podcasts/4.json * /podcasts/4.html * /podcasts/4.zip */ Route::get('/podcasts/{id}', 'PodcastsController@show')->multiformat();, (*4)

/** * Use Request::match() to return the right response for the requested format. * * Supports closures to avoid doing unnecessary work, and returns 404 if the * requested format is not supported. * * Will also take into account the Accept header if no extension is provided. */ class PodcastsController { public function show($id) { $podcast = Podcast::findOrFail($id);, (*5)

    return request()->match([
        'html' => view('podcasts.show', [
            'podcast' => $podcast,
            'episodes' => $podcast->recentEpisodes(5),
        ]),
        'json' => $podcast,
        'xml' => function () use ($podcast) {
            return response($podcast->toXml(), 200, ['Content-Type' => 'text/xml']);
        }
    ]);
}

} ```, (*6)

Contributing

Please see CONTRIBUTING for details., (*7)

Security

If you discover any security related issues, please email soy@miguelpiedrafita.com instead of using the issue tracker., (*8)

Credits

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

17/02 2018

dev-master

9999999-dev https://github.com/m1guelpf/laravel-multiformat

Multiformat Endpoints in Laravel

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

laravel m1guelpf multiformat

17/02 2018

v1.0

1.0.0.0 https://github.com/m1guelpf/laravel-multiformat

Multiformat Endpoints in Laravel

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

laravel m1guelpf multiformat