Download the PHP package bwt-team/laravel-api without Composer
On this page you can find all versions of the php package bwt-team/laravel-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-api
English description | Russian description
Laravel 5 API
This package allows to easily and quickly setup basics for API.
Content
- Installation
- Setup in Laravel
- Setup in Lumen
- License
Installation
Install this package with composer using the following command:
Setup in Laravel
When composer updated, add service provider into providers
array in config/app.php
.
This service provider will register api
macros for more comfortable work.
You will have the following format of call available in api
format:
In full format it will look as following:
Also, this service provider will allow to publish config file in order to update package settings according to your needs. Use the following command for publication:
To make all responses (including alerts etc) be sent in the same format, change class parent to \BwtTeam\LaravelAPI\Exceptions\Handler
in App\Exceptions\Handler
class
And middleware \BwtTeam\LaravelAPI\Middleware\Api
should be connected to specific path (or the whole app) to make this path be handled as API method.
If you are using App\Http\Requests
class instances for validation, you need to inherit from BwtTeam\LaravelAPI\Requests\ApiRequest
, rather than Illuminate\Foundation\Http\FormRequest
.
Setup in Lumen
After composer update register a service provider, by adding the following lines into bootstrap/app.php
:
Copy config file vendor/bwt-team/laravel-api/config/api.php
into config directory, which is stored in root directory (or create it yourself if it is missing) and set it up according to your needs.
To load settings from this file in bootstrap/app.php
add the following lines:
To make all responses (including alerts etc) be sent in the same format, change class parent to BwtTeam\LaravelAPI\Exceptions\LumenHandler in App\Exceptions\Handler
And middleware \BwtTeam\LaravelAPI\Middleware\Api
should be connected to specific path (or the whole app) to make this path be handled as API method.
License
This package is using MIT.