Download the PHP package cerbero/query-filters without Composer

On this page you can find all versions of the php package cerbero/query-filters. 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 query-filters

Query Filters

Author PHP Version Laravel Version Octane Compatibility Build Status Coverage Status Quality Score Latest Version PSR-12 Total Downloads

SensioLabsInsight

Query Filters was fully inspired by this lesson on Laracasts, it provides a simple way to filter Eloquent models based on query parameters of an HTTP request.

Install

Via Composer:

If your version of Laravel is prior to 5.5, you can register this package service provider by adding the following line to the list of providers in config/app.php:

This package includes a generator for query filter classes that by default are generated in app/QueryFilters. If you prefer a different path, you can set it in the config/query_filters.php file after running:

Usage

Imagine to have a route for indexing all actors stored in the database. This route accepts query parameters to filter records, for example:

In this case the route will need to display only actors who won at least one Oscar, are no longer acting but acted in 2000.

This can be achieved by generating a query filters class and optionally defining the allowed query parameters and related variable names via the following Artisan command:

That command will generate and populate with filters the ActorFilters class:

Please note how filter names are the equivalent camel case form of their related query parameters.

Filters are only applied if their query parameter is present in the HTTP request with a non-empty value, unless they need no value to function (e.g. won_oscar).

The $query property lets filters determine how queries change when they are applied:

After filters are defined, Eloquent models can apply them by using the FiltersRecords trait:

Finally in your route you can filter actors by calling the method filterBy() of your model and passing the query filters:

Alternatively you can hydrate query filters from a plain array:

Sometimes you may want to silently skip filters if their value is not valid. Instead of setting validation rules in HTTP requests, you may define them in the query filters class.

This avoids a failed validation to stop the filtering process and applies only valid filters while ignoring filters with values that do not pass the validation:

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of query-filters with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6||^7.0||^8.0
illuminate/http Version >=5.4
illuminate/database Version >=5.4
illuminate/console Version >=5.4
illuminate/support Version >=5.4
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 cerbero/query-filters contains the following files

Loading the files please wait ....