Download the PHP package alifcoder/query-filter without Composer

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

Alif Query Filter

Explicit, validated filtering for Laravel Eloquent and Query Builder. Keep controllers small and use the normal builder for pagination and retrieval.

Inspired by Kettasoft Filterable, with one parser and query compiler, bounded input, and no automatic result caching. See the architecture and reference review.

Current release: v2.1.0. It lets Field::custom() fields be searched and sorted through their own callback, a lighter $withShort eager-load set for short=1 lists, and single-validator operand checks; it is backward compatible with v2.0.0. Applications using v1.x must follow the upgrade guide before adopting this API.

Install

Requires PHP 8.3 or higher and Laravel 11 or higher. Each Laravel release's own PHP requirement also applies; Laravel 13 requires PHP 8.3+.

Laravel discovers the service provider and its model-filter generator automatically.

Define the public fields

Create one concrete filter for each model, such as ProductFilter. Both base classes are abstract; public fields belong in the model filter's fields() method.

Field::related() uses EXISTS, including for collections. It cannot duplicate parent rows and is not sortable. Field::make('category.name') instead uses a reusable join for a BelongsTo or HasOne relation and supports related sorting.

Field::type(FieldType::Date) declares the value type of a field (FieldType: String, Integer, Decimal, Boolean, Date, DateTime, Time, Uuid). It only sets the Field::$type metadata (default null) for consumers; it never changes filtering, searching or sorting.

Apply it

The trait is optional:

Default relations

Declare protected static array $with in a model filter to eager load relations when results are retrieved. Override these defaults for one filter instance:

setWith([]) disables only the filter's defaults. Caller and model eager loads remain, and their constraints take precedence for matching relation names. Laravel's nested relation, selected-column and closure array syntax is supported. Keep relation declarations in application code; request input cannot choose relations automatically. See eager loading.

Restrict record access

Add trusted access conditions before request filters. On an authenticated route, take the branch from the current user, not a query parameter:

For a rule shared by every use of a filter, override its protected before() method. Access predicates run even with empty input and remain ANDed with caller and request conditions. Hooks accept WHERE predicates only; configure joins and ordering on the caller's builder, and eager loading there or through $with. See the access hook examples.

Query Builder

BaseQBFilter uses the same fields, operators, validation and access hooks:

Query Builder maps SQL columns explicitly; Eloquent relation discovery belongs to BaseEBFilter. Both bases share the same parser and query compiler.

Request format

Dotted public names go inside brackets: filter[created_by.name][eq]=Ali. String values are preserved; URLs and timestamps are never split on colons.

Use JSON for grouped conditions:

Pass JSON explicitly with new ProductFilter($request->json()->all()). filter, where, and search groups are ANDed with existing query constraints. Unknown fields, disallowed operators, malformed values, and excessive requests raise Laravel ValidationException (422 for JSON requests). Authorization failures raise AuthorizationException (403).

Capabilities

is_empty=true matches SQL NULL or an exact empty string; false matches values that are neither. Zero, false, whitespace, empty JSON arrays and empty JSON objects are values. This rebuild removes the old APIs and requires application updates; see the v2.0 upgrade guide.

Read the API guide for all operators, hooks, limits, relation semantics, migration steps, and performance guidance. See the examples and recipes for a complete filter and copyable examples covering every feature, including advanced composition. See JSON columns and relations for a brand_id accessor backed by assignments->brand_id, including PostgreSQL indexes.

Development

Tests execute against SQLite, with PostgreSQL JSONB integration tests enabled in a dedicated CI job. MySQL/MariaDB coverage checks SQL compilation only. The CI matrix covers compatible PHP 8.3–8.5 and Laravel 12–13 combinations. See the PostgreSQL test instructions to run those cases locally. Benchmark results are local measurements, not database performance guarantees.

Laravel 11 is permitted by the package requirements, but fresh verification is currently blocked by dependency security advisories. Future major versions are permitted by Composer and require compatibility verification when released.

The lockfile reflects the development runtime. For a different PHP/Laravel combination, resolve dependencies with composer update, as the CI matrix does.

License

MIT © Shukhratjon Yuldashev


All versions of query-filter with dependencies

PHP Build Version
Package Version
Requires illuminate/auth Version ^11.0 || ^12.0 || ^13.0
illuminate/console Version ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
illuminate/validation Version ^11.0 || ^12.0 || ^13.0
php Version >=8.3
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 alifcoder/query-filter contains the following files

Loading the files please wait ...