Download the PHP package monterhealth/api-filter-bundle without Composer

On this page you can find all versions of the php package monterhealth/api-filter-bundle. 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 api-filter-bundle

MonterHealth ApiFilterBundle

MonterHealth ApiFilterBundle makes it easy to add filters and ordering to Rest API requests with full control within your Symfony Controller classes. Inspired by the filter system of API Platform but with its focus on usage within a controller.

Installation

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

Usage

First define what combinations of parameters and filter typs can be used. This is possible by adding attributes to an entity class. Load the MonterHealth/ApiFilterBundle/MonterHealthApiFilter in your controller and pass it a Doctrine QueryBuilder, the entity's class name and the Request query. It will add all the constraints and orderings of the Request query to the QueryBuilder.

Entity

Add attributes to an entity class. You can add them at class or property level. The bundle can handle nested properties like author.name multiple levels deep.

Controller

Load the MonterHealth/ApiFilterBundle/MonterHealthApiFilter service into your controller using auto wiring.

Filters

Boolean filter

Query: parameter=<true|false|0|1>

For example:

/books?available=true shows all books that are available.

Search filter

Available strategies:

Query: parameter[strategy]=value or parameter[][strategy] when setting multiple constraints on the same parameter. Add [not] before or after the strategy to get the opposite filter effect.

For example:

/books?author:name=agatha%20christie returns all books where author.name equals 'agatha christie'.

/books?author[not][end]=rowling returns all books where author doesn't end with 'rowling'.

/books?author:author[in]=agatha%20christie|j.k.%20rowling returns all books where author matches 'agatha christie' or 'j.k. rowling'.

/books?title[][start]=harry&title[][not][word_start]=philosopher returns all books that have a title that starts with 'harry' and where none of the words in the title start with 'philosopher'.

/books?title[null] returns all books where the title is null. The null strategy doesn't need any extra value.

The in strategy includes the option to include NULL values. For example:

/books?author:id[in]=48|24|NULL returns all books where the author id matches 48 or 24, and all books that have no author set.

/books?author:id[not][in]=48|24|NULL returns all books where the author id doesn't match 48 and 24, and all books that have no author set.

As you may have noticed, nested properties must be referenced with a : sign like author:name in the uri.

Order filter

Available strategies:

Query: order_parameter_name[strategy]=parameter or order_parameter_name[][strategy]=parameter with multiple orderings.

For example:

/books?order=author:name orders the list by author in the default direction (ascending) or in the direction set on the entity.

/books?order[desc]=author:name orders the list by author in descending direction.

/books?order[][asc]=author:name&order[][asc]=title orders the list by author in ascending direction and by title in ascending direction.

Numeric filter

Query: parameter=value

For example:

/books?stock=10 return all the books that have 10 stock.

Range filter

Available strategies:

Query: parameter[strategy]=value OR parameter[][strategy]=value when setting multiple constraints on the same parameter.

For example:

/books?stock[lte]=10 return all the books which stock is less than equal to 10.

/books?stock[bt]=0|10 return all the books which stock is between 0 and 10.

Date filter

Available strategies:

Query: parameter[strategy]=value OR parameter[][strategy]=value when setting multiple constraints on the same parameter.

For example:

books?createdAt[before]=2020-12-04 return all the books which createdAt <= 2020-12-04

books?createdAt[][after]=2020-12-01&createdAt[][before]=2020-12-04 return all the books which createdAt >= 2020-12-01 AND <= 2020-12-04

Configuration

Upgrade to version 2

To upgrade to version 2 it is advised to use rector. Add a configuration rule to convert the ApiFilter annotations to attributes:


All versions of api-filter-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
symfony/orm-pack Version *
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 monterhealth/api-filter-bundle contains the following files

Loading the files please wait ....