Download the PHP package api-skeletons/doctrine-orm-querybuilder-filter without Composer

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

Doctrine ORM QueryBuilder Filter

Build Status Code Coverage PHP Version

Apply filters to a QueryBuilder based on request parameters. Supports deep queries using joins. This repository is intened to apply query parameters to filter entity data.

Installation

Run the following to install this library using Composer:

Quick Start

Filters

The pattern for creating a filter is filter[fieldName|operator]=value This pattern is an easy way to define complex queries utilizing all the filtering capabilities of the QueryBuilder.

The following URL will provide a LIKE filter for a user's name:

These operators are supported:

You may use as many filters as you wish. Filters operate on the field names of the entity and on the association names. This allows you to filter on an assocaition. For instance, to filter a list of users by company where the id of the company is known and the Doctrine metadata is correct you may filter like this:

So even though there is not a field named company there is an association and that is filterable though this tool.

Filtering on single entities

The configuration of the Applicator allows you to enable assocaition filtering, but this is disabled by default. So, assuming the default setting, this is a complex filter on a single entity:

Filtering on the hierarcy of entities

The configuration of the Applicator allows you to enable assocation filtering. This means you can filter the current entity based on fields with an association with the current entity and you may do so as deep as you wish.

In this example we'll pull user data based on their company by name:

In this example we'll pull user data based on their company by company type by company type name:

Before you get too concerned about this ability remember you can modify the QueryBuilder after it has had filters applied to it so if you need to apply security settings that is supported.

A note on sorting

While sorting isn't by strict definition a filter, it falls into the same context when requesting data. You can sort by multiple fields and you can sort across associations (if enabled). Sorting is prioritized left to right.

Use

This is the minimum required to use this library:

This is an example of configuring the applicator with all possible options

After a QueryBuilder is returned with the filters applied to it you may modify it as desired before using it to fetch your result.

Real world Laravel example

In this example, data from the Entity\Style entity is returned using HAL in a paginated response in a controller action.

Configuration

Using the Applicator is strait-forward and many options for configuring it are available. Begin by creating the Applicator then run configuration functions:

enableAssociations()

This configuration method turns on deep filtering by using the Doctrine metadata to traverse the ORM through existing joins to the target entity. This is only possible in a Doctrine installation with complete metadata and proper associations between entities defined in the metadata.

removeOperator(string|array)

If you want to disable any operator you may remove it. A good example is the like operator which could result in expensive queries.

setEntityAlias(string)

The default alias used when creating filters for the target entity in the QueryBuilder is entity. You may want to change this so you know the alias after the QueryBuilder is returned and you can add additional parameters to it.

setFieldAliases(array)

If you want the filter to alias a field instead of using the ORM field name (such as using naming strategies in hydrators) you may pass an array of [alias => field] values so mapping can be adjusted.

setFilterableFields(array)

By default all fields on the target entity can be filtered. If you want to limit which fields your users can create filters for then pass those field names in this array.

getEntityAliasMap()

This method is for post-processing of the target entity. When users use deep filtering using enableAssociations() aliases are created for every entity joined to the original entity query. This method returns an array of [alias => entityClass] for all entities joined in the QueryBuilder.


All versions of doctrine-orm-querybuilder-filter with dependencies

PHP Build Version
Package Version
Requires php Version ~7.4||^8.0
doctrine/orm Version ^2.8
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 api-skeletons/doctrine-orm-querybuilder-filter contains the following files

Loading the files please wait ....