Download the PHP package william/laravel-rigger without Composer
On this page you can find all versions of the php package william/laravel-rigger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-rigger
laravel-rigger
Laravel Rigger is inspired by facebook/graphql, which is a query language for APIs. But I think its granularity is too thin to use in web development area. Using entity as query's minimum unit is better to generate a restful back-end swiftly based on a few necessary configuration, which describe the entities and relations.
Table of contents
- Installation
- Composer
- Laravel
- Entity Description
- Relations
- Query
- Include
- Authenticate and Authorize
Installation
Composer
Laravel
Only support Laravel >= 5.5, and the ServiceProvider will be attached automatically. Publish entity config is necessary:
This will generate config/entities.php
and config/rigger.php
files.
Then register the routes in RouteServiceProvider
:
You can use this command to check generated routes.
Entity Description
All the models/entities wanted to be handled by rigger should be
defined in config/entities.php
.
Relations
Support four relations: hasOne
belongsTo
hasMany
belongsToMany
. Items
in these arrays can be an array or a string. Take User
as an example, User
may
have many Role
s through user_role
table, so you can define it like this:
If you want to modify the joining table, you can use an array:
All these definitions are consistent to the doc in https://laravel.com/docs/5.5/eloquent-relationships
Query
This part is powered by andersao/l5-repository, and its most exciting function is allow front-end to perform a dynamic search, filter the data and customize the queries. Check the Reference
Fields which can be searched by this way should be defined in config/entities.php
. For example:
Include
This part is powered by spatie/laravel-fractal, and
it allows front-end to include (a.k.a embedding, nesting or side-loading) relationships for complex data structures.
For example, when you are querying /users
, you may want to know their roles information at the same time. So
you can add include
parameters, like /users?include=roles
:
All the relations defined in hasOne
belongsTo
hasMany
and belongsToMany
can be fetched by this way.
If you want to add some limitations, you can add availableIncludes
array to your entity. If so, keys only
in the array can be parsed even though they defined in relations.
Authenticate and Authorize
Rigger use spatie/laravel-permission as basic validator.
There are three control layers in rigger: global layer, entity layer and action layer.
In every layer, there exist two key words authorize
and authenticate
to control the behaviour.
authorize
describes which permissions or roles are needed, and authenticate
determines whether the user need to
login.
authenticate
Only true
of false
can be set
authorize
role
and permission
are supported. You can alse set placeholder
${action}
${resource}
in the permission. For example, if you set permission
as ${action}-${resource}
in user item, when visiting GET /users
, permssion index-user
will
be required.
three control layers
When visiting a specific action, it will check whether this resource has a detailed action-control,
if so, then parse it. If not, it will use entity-control. However, if entity-control doesn't exist,
global-control will active which located in rigger.php
All versions of laravel-rigger with dependencies
illuminate/support Version ^5.5
illuminate/routing Version ^5.5
prettus/l5-repository Version ^2.6
spatie/laravel-permission Version ^2.7
spatie/laravel-fractal Version ^5.3