Download the PHP package gomoob/php-value-filter-dsl without Composer

On this page you can find all versions of the php package gomoob/php-value-filter-dsl. 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 php-value-filter-dsl

php-value-filter-dsl

Powerful filter DSL PHP library for REST Web Services query / URL parameters or other filtering needs.

Total Downloads Latest Stable Version Build Status Coverage Code Climate License

Sample with not in

Suppose you have a Web Service accessible using https://api.myserver.com/users and want to create a filter to find users not having a first name equals to Jack, Joe, Willian or Averell.

To do this you'll have to request your relationnal database with a not in SQL request. The php-value-filter-dsl library allows you to parse a custom filter expression from an URL query parameter and convert it into an equivalent SQL expression you can use in your SQL query builder.

Our filter expression language is a custom one designed by Gomoob to respond to lots of REST Web Services API filtering needs, this filter expression is thorougly described in our documentation.

Filtering to exclude the 4 first names described previously would be done using the following GET HTTP request.

The PHP source code used to parse the filter expression (i.e the first_name URL query parameter value) is the following.

The previous sample will execute the SQL query select * from users where first_name not in('?','?','?','?') with the prepared statement parameters Jack, Joe, Willian, Averell.

Very simple and useful, isn't it ?

Please note that for now we only provide convertion of filter expressions in SQL. Later we'll extend the library to provide additional converters to transform the filters into other formats.

Documentation

Standard operators

The expression language provides the following operators.

Operator ASCII value Name Value type(s)
= %3D Equals Integer, Float, String
< %3C Less than Integer, Float
<= %3C%3D Less than or equal to Integer, Float
> %3E Greater than Integer, Float
>= %3E%3D Greater than or equal to Integer, Float
in In Integer list, Double list, String list
~ %7E Like String
! %21 Not see description above
+ %2B And see description above
- %2D Or see description above

Not operator

The ! operator is special, it can be used directly before a value string or in combination with the = or in operators.

For exemple !5 or !=5 to express "not equals to 5" or !in('Paris','London') to express "not equals to Paris or London".

AND and OR operators

The + and - operator allow to create AND and OR SQL requests.

Here are sample expressions with logical operators.

Like operator

The ~ operator allows to create like SQL requests, but it is always converted to expressions equals to my_property like ? with a value equals to %word% which is not always wanted.

To express more complex like expressions you can use the * string operator in the value associated to the = or ~ operators.

For example property=~'*Nantes*France*' or property='Nantes*France*' will be translated to property like ? with a parameter equals to %Nantes%France%.

Values

The following values can be used.

Date and time parsing

By default when the SqlFilterConverter encounters a string inside an expression it simply takes it as a "standard" string.

But you've probably business entities having date attributes and want to request those entities using data and time filters. To do this you can set a date and time parser on the SqlFilterConverter to indicate him to parse date and time string and transform them to date and time string which are compliant with the database in use.

For example configuring the SqlFilterConverter to parse ISO 8601 strings and convert them to MySQL date and time format is done with the following.

By default the FormatDateTimeParser class uses ISO 8601 date and time parsing, but you can change its behavior with the FormatDateTimeParser->setFormat(string $format) method. In generall you'll want to use one of the format provided with the PHP DateTime class, that's to say one of DateTime::ATOM, DateTime::COOKIE, DateTime::ISO8601, DateTime::RFC822, DateTime::RFC850, DateTime::RFC1036, DateTime::RFC1123, DateTime::RFC2822, DateTime::RFC3339, DateTime::RSS or DateTime::W3C.

The parser parses date and time strings and convert them to PHP DateTime object, then internally the SqlFilterConverter converts the DateTime object to a string which is compatible with Mysql.

For example the following transform will create a property <= ? expression with a value equals to 2017-12-01 06:00:00 which is compatible with MySQL.

About Gomoob

At Gomoob we build high quality software with awesome Open Source frameworks everyday. Would you like to start your next project with us? That's great! Give us a call or send us an email and we will get back to you as soon as possible !

You can contact us by email at [email protected] or by phone number (+33) 6 28 35 04 49.

Visit also http://gomoob.github.io to discover more Open Source softwares we develop.


All versions of php-value-filter-dsl with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.0
guzzlehttp/guzzle Version ^6.2.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 gomoob/php-value-filter-dsl contains the following files

Loading the files please wait ....