Download the PHP package mdantas/express-request without Composer
On this page you can find all versions of the php package mdantas/express-request. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mdantas/express-request
More information about mdantas/express-request
Files in mdantas/express-request
Package express-request
Short Description ExpressRequest plugin for CakePHP
License MIT
Informations about the package express-request
ExpressRequest plugin for CakePHP
Something about package
This package help me a lot with query url, maybe it will help you, often when I try to make api's I tried to make complex url, complex querystring parameters and I felt frustrated, because something did not make sense. After poc's and poc's and good companion's help, I've come to this conclusion.
How this package can help you
Instead of make more and more complex url query params or many endpoints, let's try to produce what really model can be to customers, goto code.
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
Add plugin to our Application.php
``
Express your filter's on model
Our table object needed implement ExpressRepositoryInterface
make new methods.
``
Controller
In Controller/AppController.php
load component called: ExpressRequest.ExpressParams
and now, add some code to our DomainsController.
*Of course, don't forget to add a route to this controller.
Request
Let's see how your /domains
endpoint is now more friendly for the requests/resources.
Open in the browser: http://localhost:8765/domains?price=140..3000&sort[price]=asc&type[not]=profit&size=1
``
Details
I've talked about this help me a lot, right? now, see how this stuff works.
Every requests is treat on ExpressRequest.ExpressParams
this component
try to understand what the request need and with help of model it reproduces a response,
some operations or conditions by the users can be dangerous or simple introduces requests
errors on application because the request is wrong, for this reason, model express to
component what it can do, if it can't, nothing occur, and think, what if we try to search 'A'
on boolean typed data? For this reason some typed filters are implemented.
Select only fields.
``
Sorting data
for each field, have two values: asc, desc. ``
Contained data
Sometimes we need to retrieve data with relationship, of course, it's can be easily. `` Need to add complex or conditions to your related data, the simple awnser is: you can't, and you shouldn't try, if you need some complex related data see: CakePHP docs
Filters
Powerfully and secure filter's:
BooleanFilter
Filter by boolean values ? like 'true', 'false', '1', '0'
NumberFilter
can filter data by numbers with some helps. ``
NullFilter
This filter simple execute is or is not null on query. ``
SearchFilter
This filter have four methods of work:
SearchInFilter
filter by value or group values. ``
SearchDateFilter
2.0.1 is possible to use [gte, gt, lt, lte]
operators.
``
Custom Filter ?
By implementing FilterTypeInterface
and if you want ProcessableFilterTrait
you can create a filter for what you need.
About Component
The component have a list of configurations values to work above
query params, without reserved
keys it try to filter content, if model
accept it, url queries
Change some configs...