Download the PHP package isma/api-filters-bundle without Composer

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

🎯 API Filters Bundle

CI PHP Symfony PHPStan Code Style

A Symfony bundle that resolves API query filters from HTTP requests and applies them to query builders using a strategy pattern. Declare allowed filters with PHP attributes on your controller actions, and the bundle handles parsing, validation, and query building automatically.

πŸ“‹ Requirements

πŸ“¦ Installation

If you're using Symfony Flex, the bundle is automatically registered. Otherwise, add it to config/bundles.php:

πŸš€ Quick start

1. Add #[ApiFilter] attributes to your controller

2. Send a request with filters

Filters also support arrays (for eq, neq, like, ilike, inotlike, ieq, inoteq, start_with, end_with):

3. Apply filters to a Doctrine query builder

βš™οΈ The #[ApiFilter] attribute

Parameter Type Default Description
name string (required) The filter field name used in the query string
allowedTypes string[] [] (all types) Restrict which filter types can be used. Empty = all types allowed
enumClass class-string<BackedEnum>\|null null Validate and cast the filter value against a backed enum

Restricting filter types

If a client sends a disallowed type, a 400 Bad Request is returned.

Enum validation

The value is validated against the enum cases. Invalid values return a 400 Bad Request.

4. Apply filters using DBAL (without ORM)

If you don't use Doctrine ORM, you can use the DBAL filter applier with a raw Doctrine\DBAL\Query\QueryBuilder:

5. Apply filters using Pure SQL (PDO β€” no Doctrine required)

If your project doesn't use Doctrine at all, you can use the Pure SQL filter applier with a raw PDO connection:

πŸ”Ž Built-in filter types

The bundle ships with 15 filter strategies for ORM, DBAL, and Pure SQL:

Type Query string Scalar DQL Array DQL
eq filters[field][eq]=value field = :param field IN (:param)
neq filters[field][neq]=value field != :param field NOT IN (:param)
like filters[field][like]=value field LIKE '%val%' OR of LIKE clauses
ilike filters[field][ilike]=value LOWER(field) LIKE LOWER('%val%') OR of LIKE clauses
inotlike filters[field][inotlike]=value LOWER(field) NOT LIKE LOWER('%val%') AND of NOT LIKE clauses
ieq filters[field][ieq]=value LOWER(field) = :param LOWER(field) IN (:param)
inoteq filters[field][inoteq]=value LOWER(field) != :param LOWER(field) NOT IN (:param)
start_with filters[field][start_with]=value field LIKE 'val%' OR of LIKE clauses
end_with filters[field][end_with]=value field LIKE '%val' OR of LIKE clauses
gt filters[field][gt]=value field > :param ❌ throws exception
gte filters[field][gte]=value field >= :param ❌ throws exception
lt filters[field][lt]=value field < :param ❌ throws exception
lte filters[field][lte]=value field <= :param ❌ throws exception
is_null filters[field][is_null]=true field IS NULL / field IS NOT NULL ❌ throws exception
order filters[field][order]=asc ORDER BY field ASC/DESC ❌ throws exception

Notes:

🧩 Creating a custom filter strategy

Implement FilterStrategyInterface and the bundle will auto-discover it:

The strategy is automatically tagged with isma_api_filters.strategy and collected by OrmFilterApplier. No manual service registration needed.

Creating a custom DBAL filter strategy

For DBAL, implement DbalFilterStrategyInterface:

The strategy is automatically tagged with isma_api_filters.dbal_strategy and collected by DbalFilterApplier.

Creating a custom Pure SQL filter strategy

For pure SQL (PDO), implement SqlFilterStrategyInterface:

The strategy is automatically tagged with isma_api_filters.sql_strategy and collected by SqlFilterApplier.

Naming convention: To avoid any collision with current or future built-in filter types, prefix your custom filter names with x- (e.g. x-between, x-fulltext). This ensures your custom strategies will never conflict with a type added to the bundle in a later version.

You can then use it immediately:

⚠️ Error handling

Scenario Exception HTTP status
Unknown filter field InvalidFilterException 400
Disallowed filter type InvalidFilterException 400
Invalid enum value InvalidFilterException 400
Malformed filter format InvalidFilterException 400
Missing field mapping in apply() \InvalidArgumentException 500
Duplicate strategy for same type DuplicateFilterStrategyException Container build error

πŸ—ΊοΈ Roadmap

πŸ“„ License

MIT - see LICENSE for details.


All versions of api-filters-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
symfony/config Version ^6.4 || ^7.4 || ^8.0
symfony/dependency-injection Version ^6.4 || ^7.4 || ^8.0
symfony/http-foundation Version ^6.4 || ^7.4 || ^8.0
symfony/http-kernel Version ^6.4 || ^7.4 || ^8.0
doctrine/dbal Version ^4.0
doctrine/orm Version ^3.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 isma/api-filters-bundle contains the following files

Loading the files please wait ...