Skip to content

evgeny-l/rest-api-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Handles Laravel REST API basic methods.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages