Download the PHP package flsouto/pipe without Composer

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

Pipe

Overview

This library exposes a simple API that allows you to apply a chain of filters and/or validators against arbitrary data.

Installation

Through composer:

Usage

The following example adds a 'trim' filter and a custom filter which replaces 4, 1 and 0 with a,i and o:

The above code will output:

So all your filter function has to do is to accept a value, modify and return it.

Validation

The next example uses the same API but this time makes sure the input value doesn't have a number '4'.

The above snippet outputs:

So, if your filter prints something out, then it is considered to be a validator instead of a regular filter. The printed error message will be available in the $result->error property.

Using Filters and Validation Together

In the following code snippet you have a filter happening before the validation, so the validation does not failed.

This is just to ilustrate that filters and validators can work together. Notice the order they are applied is the same order they are added to the pipe.

Defining a Fallback

The fallback method allows you to define a default value to be returned in case any error occurs. The default fallback is always the input itself:

Use the fallback method to change the default value:

The output will be:

Notice: the fallback value is also used when the input value is null. Example:

The output will be:

However this behaviour does not follow on empty strings:

Customizing the fallback behaviour

If you want, for instance, to fallback on null, empty string or zero, you have to provide the second parameter to the fallback method:

The output will be:

Alternative syntax

You can use the addArray method to add an array of filters at once or you can instantiate the Pipe class through the create method which accepts an array of filters too:

Final Thoughts

There are no final thoughts - this is just the beginning (:


All versions of pipe with dependencies

PHP Build Version
Package Version
No informations.
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 flsouto/pipe contains the following files

Loading the files please wait ....