Download the PHP package bravepickle/query-filters-serializer without Composer

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

README

Serializer of query filters from arrays or strings. Provides constraints and parsing logic for preconfigured filters

Description

This is a PHP library that provides serialization/deserialization of abstract filters using query string, compatible with URL format. The main purpose of this library is to help developers to make more or less standard filters within URIs and convert it to neatly formed structure for further usage. Also it can provide (optionally) SQL builder that helps to append those filters to SQL queries. It is more less SQL implementation independent and can be used in various DBs: Doctrine, MySQL, SphinxQL etc.

Filters can be easily configured using configs per each field

Contents

  1. Installation
  2. Features
  3. Usage
    1. String Format
      1. Additional Examples
    2. URL Query Format
      1. Additional Examples
  4. Configuration
  5. Advanced Usage
  6. TODOs

Installation

Add to composer.json

  1. Add dependency to composer.json

  2. Install new dependencies

Features

Usage

Currently only 2 query serializer formats supported: String and URL Query. You can implement your own using existing ones as examples. To see more usage examples, please refer to the provided tests

String Format

This is a custom string format that implements simple and efficient way to set filters. It is short, human readable. See example below

The main drawback may lie in its proper formatting on client side and escaping all special chars used for it, is more error prone than URL Query format when used without careful thinking beforehand. The good thing is that its that those are customizable and you can change them if needed or ensure that they won't appear in your queries

Additional examples

Input Config Description
name:John, hello ['constraints' => ['name' => ['type' => 'string', 'name'=> 'title']]] Will search for string "John, hello" within field "title" (see config)
name:John;hello;!Jake;Jim! ['constraints' => ['name' => ['type' => 'string', 'options' => ['use_not' => true, 'multiple' => true]]]] Will search for names, that conatin words "John" and "hello" and does not contain words "Jake" and "Jim"
status:active ['constraints' => ['status' => ['type' => 'string','options' => ['allowed' => ['active', 'passive']]]]] Will search status that equals to "active". If given value will not have either "active" or "passive" words, then error will be thrown
email:[email protected];id:=2 ['constraints' => ['email' => ['type' => 'string'], 'id' => ['type' => 'integer']]] Contains complex filters. Will search records that have email equal to "[email protected]" and id equal to "2"
age:>=14,<20 ['constraints' => ['age' => ['type' => 'integer']],'build_sql' => true] Integer range filter
date_from:>=2015-11-28T16:59:13UTC,2015-9-28T16:59:13UTC ['constraints' => ['date_from' => ['type' => 'datetime']]] Will convert this set to =2015-08-28T16:59:13UTC. Datetime search
user:(name:John;status:active) ['constraints' => ['user' => ['type' => 'embedded', 'options' => ['constraints' => ['name' => ['type' => 'string'],'status' => ['type' => 'string']]]]]] Embedded search. Will search for records that have reference to entity "user", which have name "John" and status "active"
age:<23,<2,<10 ['constraints' => ['age' => ['type' => 'integer']]] Will format it to age < 2
age:18,20,21 ['constraints' => ['age' => ['type' => 'integer']]] Will search for records that have age either 18, or 20 or 21. (SQL IN(...))

URL Query Format

This option is easily implemented on client side and is based regular URL query string format. It may be parsed automatically by your PHP application or by serializer itself from string. Can be sent directly in HTML forms and may support the most complex cases for filtering data

This is longer variant of query filtering, less human readable. Better for embedded and custom filter types to support due to its solid URI component formatting rules supported by client & server from start.

If you need to use it as single GET param in URI it is possible to use formatting as following: 'http://example.com?filter=' + urlencode('_[foo]=bar&_[num]=>baz').

Additional examples

Input Config Description
_[name]=John, hello ['constraints' => ['name' => ['type' => 'string', 'name'=> 'title']]] Will search for string "John, hello" within field "title" (see config)
_[name][]=John&_[name][]=hello&_[name][]=!Jake&_[name][]=Jim! ['constraints' => ['name' => ['type' => 'string', 'options' => ['use_not' => true, 'multiple' => true]]]] Will search for names, that conatin words "John" and "hello" and does not contain words "Jake" and "Jim"
_[status]=active ['constraints' => ['status' => ['type' => 'string','options' => ['allowed' => ['active', 'passive']]]]] Will search status that equals to "active". If given value will not have either "active" or "passive" words, then error will be thrown
_[email][email protected]&_[id]=2 ['constraints' => ['email' => ['type' => 'string'], 'id' => ['type' => 'integer']]] Contains complex filters. Will search records that have email equal to "[email protected]" and id equal to "2"
_[age][]=>=14&_[age][]=<20 ['constraints' => ['age' => ['type' => 'integer']],'build_sql' => true] Integer range filter
_[date_from][]=>=2015-11-28T16:59:13+03:00&_[date_from][]=2015-9-28T16:59:13UTC ['constraints' => ['date_from' => ['type' => 'datetime']]] Will convert this set to =2015-08-28T16:59:13UTC. Datetime search
_[user][name]=John&_[user][status]=active ['constraints' => ['user' => ['type' => 'embedded', 'options' => ['constraints' => ['name' => ['type' => 'string'],'status' => ['type' => 'string']]]]]] Embedded search. Will search for records that have reference to entity "user", which have name "John" and status "active"
_[age][]=<23&_[age][]=<2&_[age][]=<10 ['constraints' => ['age' => ['type' => 'integer']]] Will format it to age < 2
_[age][]=18&_[age][]=20&_[age][]=21 ['constraints' => ['age' => ['type' => 'integer']]] Will search for records that have age either 18, or 20 or 21. (SQL IN(...))

Configuration

TBD

Advanced Usage

TBD

TODOs

License

MIT


All versions of query-filters-serializer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
ext-mbstring 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 bravepickle/query-filters-serializer contains the following files

Loading the files please wait ....