Download the PHP package fuzz/api-server without Composer
On this page you can find all versions of the php package fuzz/api-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fuzz/api-server
More information about fuzz/api-server
Files in fuzz/api-server
Package api-server
Short Description A framework for rapid REST API development.
License MIT
Informations about the package api-server
Laravel API Server
A framework for rapid REST API development.
Installation
- Require the repository in your
composer.json
- Add the
ApiServerServiceProvider
to your application and publish its configartisan vendor:publish --provider="Fuzz\ApiServer\Providers\ApiServerServiceProvider"
. -
Extend the packaged route provider for your app:
- Extend the packaged exception handler for your app:
Usage
Basic usage
Register a base controller extending Fuzz\ApiServer\Routing\Controller:
Register routes pointing to extensions of your base controller. Make a catch-all route to send all other requests through your base controller.
ResourceControllers
Resource controllers extend functionality of fuzz/magic-box
repositories and provide CRUD and authorization functionality out of the box.
Your application should extend the base fuzz/api-server
Resource controller:
And to define a route for a resource in your routes.php
: $router->restful('User');
. The restful
route macro is defined in Fuzz\ApiServer\Providers\RouteServiceProvider
.
If any resources need to override the default functionality, you can create a specific ResourceController by extending your application's base ResourceController:
app/Http/Controllers/Resources/Users.php
:
You can then point your restful route to your custom ResourceController:
in routes.php
: $router->restful('Run', 'Resources\Users');
Returning that sweet, sweet, data
Send mixed data:
Send any arrayable data:
Send any paginated data:
Send RESTful errors with error codes and optional data:
Raise RESTful error exceptions outside of the controller context:
Require the user to provide certain parameters:
Read a list of certain parameters:
Special handling (with de-duplication) for reading arrays:
Handles nested JSON and form properties just fine:
CORS Middleware
Configuring the CORS middleware is as simple as adding Fuzz\ApiServer\Routing\CorsMiddleware
to the $middleware
array in app/Http/Kernel.php
.
All versions of api-server with dependencies
fuzz/laravel-data Version 1.0.x
fuzz/laravel-oauth Version 1.1.x-dev as 1.1
fuzz/magic-box Version 1.2.x-dev as 1.2
fuzz/http-exception Version 1.0.*
laravel/framework Version 5.3.*
league/csv Version ^7.2@dev
lucadegasperi/oauth2-server-laravel Version 5.2.*
maatwebsite/excel Version ^2.1