Download the PHP package gobline/filter without Composer

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

Filter component

The Filter component is used to sanitize and/or validate variables. Its power lies in the ability to define "filter funnels" which allow to filter a variable through multiple (built-in or custom) sanitizers and validators easily at once.

There are two kinds of filters:

Sanitizers

Example:

Built-in Sanitizers

Validators

Example:

Built-in Validators

Note:

A distinction can been made between two groups of validators:

This is because it is important to know that data validators may expect the variable to filter to be of a specific type, and will consequently throw an exception if the type is unexpected (e.g. Length validator expects a string), whereas data type validators will never throw exceptions.

Data type validators include: Alpha, Alphanum, Boolean, Email, Float, Int, Scalar

Data validators include: Between, Length, Max, Min, NoTags, Required, Regex, Value

Error messages

It is possible to retrieve the validator's error messages in case data failed validating.

Customization of error messages is supported:

Note that you can use placeholders as %value% above. Each validator has its own placeholders (all of the built-in validators have at least %value%). For example, the validator Between who checks if a number is between two numbers provides 3 placeholders: %value%, %min% and %max%. Its default message is: The input is not between "%min%" and "%max%" (inclusively).

Translator

You can add a translator for your error messages globally

or for an instance

Filter Funnels

The real value of the component is its ability to create filter funnels. Filter funnels allow you to filter a variable through multiple sanitizers and/or validators at once.

Below is an example that trims the variable and checks if it contains a valid age (between 0 and 110). Eventually it will cast the variable to an integer.

If one of the validators invalidates data, the funnel will return (and will not execute the sanitizers and validators that follow).

It is possible to register filters in a class map in order to reference the filters by classname when using the funnel. Built-in filters are registered in the class map by default. The example above could be rewritten as follows:

The above could also be written like:

or

or

Optional Values

or

If is an empty string or null, the filter funnel will return null without any error messages as the field is optional.

Adding Custom Filters

To add your own custom filters into the class map, use the factory class:

You can still set custom messages for validators when using funnels:

Note that should directly follow an call or an exception will be thrown.

Object Filters

You can filter an object's properties by implementing the interface.

Installation

You can install the Filter component using the dependency management tool Composer. Run the require command to resolve and download the dependencies:


All versions of filter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
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 gobline/filter contains the following files

Loading the files please wait ....