LaravelPackages.net
Acme Inc.
Toggle sidebar
evgeny-l/rest-api-core

REST API Core. Handles REST API requests and responses.

1.128
2
v0.8.0
About evgeny-l/rest-api-core

evgeny-l/rest-api-core is a Laravel package for rest api core. handles rest api requests and responses.. It currently has 2 GitHub stars and 1.128 downloads on Packagist (latest version v0.8.0). Install it with composer require evgeny-l/rest-api-core. Discover more Laravel packages by evgeny-l or browse all Laravel packages to compare alternatives.

Last updated

Laravel 5 REST API Core

Install

Require this package with composer using the following command:

composer require evgeny-l/rest-api-core

After updating composer, add the service provider to the providers array in config/app.php

EvgenyL\RestAPICore\RestAPICoreServiceProvider::class,

Publish the config file to config/rest-api-core.php

php artisan vendor:publish --provider="EvgenyL\RestAPICore\RestAPICoreServiceProvider" --tag=config

Install exceptions handler to app/Exceptions/Handler.php:

use EvgenyL\RestAPICore\Http\Exceptions\APIJSONHandlerTrait;

...
    public function render($request, Exception $exception)
    {
        if ($request->expectsJson()) {
            return $this->handleJSONResponse($request, $exception);
        }
        return parent::render($request, $exception);
    }
    
...

Install response middleware for JSON formatting into API middleware section:

\EvgenyL\RestAPICore\Http\Middleware\ResponseFormat::class

Star History Chart