Download the PHP package klips/dingoquerymapper without Composer

On this page you can find all versions of the php package klips/dingoquerymapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dingoquerymapper

dingo-query-mapper

Uses Dingo/API Request Query Parameters to filter Laravel Collections. For example, you are able to automatically filter, sort, and limit collections based on query parameters of the URI.

Installation

First, add the respective line to your composer file

and run composer install to install the new component.

Then add respective ServiceProvider from the package to your config/app.php configuration file, like this:

If you want, you can overwrite the basic configuration using the following command:

This will copy the dingoquerymapper configuration file to your config folder. Using this file, you can customize the limit parameter or the query parameters to be excluded from the service provider. This is handy, if you need to omit parameters from automatically parsed for filtering (e.g., you may want to exclude the token parameter if you are using JWT).

Usage

Example

In order to use the plugin, simply create a new instance from DingoQueryMapper and pass the request. Furthermore, you want to call respective createFromXXX() method from the DingoQueryMapper, which basically allows to create the mapper from various inputs (e.g., Collection, Builder, ...)

Consider the following example:

If you call the respective URI, for example like so:

it will output (a maximum of) 10 Users per page, where the name attribute starts with j and the age is greater or equal than 18 starting on page 3.

Dingo/API Example

If you use Dingo/API as your preferred API framework, you can use this package right away. If you are not using Dingo/API, you should really consider using it - it is awesome!

However, all of the information described above still remains when using Dingo/API. Only, the returning the results varies because you need to use Dingo's response objects.

You can simply return your results using

That's all - really!

Parameters

This plugin provides some pre-defined parameter names to be automatically filled.

limit and page

In order to limit the amount of response elements, simply add respective limit query parameter, like this:

This will only return the (first) 20 entries of the result. In order to request the next 20 entries, simply add a page parameter to the query, like this:

will return the next 20 entries that are located on page 2.

sort

In order to sort the results using different parameters, you can simply concatenate them using ,. In order to provide ASC and DESC sorting, you may prepend a - before respective attribute. Sorting is case-insensitive.

For example

sorts the results by age (ascending), then by name (descending; note the - before the name field!)

custom filters

Of course you may pass custom query parameters to the builder in order to filter the requested data. For example:

If you try to filter using a column that does not exist in the respective model, it will be ignored.

At the moment, this plugin offers the following operators:

Of course you can combine the filters with the other query parameters:

would return the first 20 elements, where the name starts with j, the age is >= 18 sorted by age ASC and name DESC.


All versions of dingoquerymapper with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
laravel/framework Version >=5.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package klips/dingoquerymapper contains the following files

Loading the files please wait ....