Download the PHP package eloquent/confetti without Composer

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

Confetti

Streaming data transformation system for PHP.

The most recent stable version is 0.3.1 Current build status image Current coverage status image

Installation and documentation

What is Confetti?

Confetti is a system for implementing streaming data transformation. It allows a single transform implementation to be used for strings, React streams, and native PHP stream filters. Confetti transforms are simple to implement, and can facilitate a wide range of stream manipulations, such as encoding, encryption, and incremental hashing.

This library contains no transform implementations. For real-world examples of data transform usage, see Endec, and Lockbox.

Transform streams

The TransformStream class provides a simple way to create a React stream wrapper around a transform. It implements both ReadableStreamInterface and WritableStreamInterface. Its usage is as follows:

The success event

In addition to the events used by React streams (data, end, close, error), The TransformStream class will emit a success event upon closing if there have been no errors. The success callback will be passed the stream, and can access the inner transform by calling $stream->transform():

Combining transforms

Any number of transforms can be combined into a single transform instance by using the CompoundTransform class. This is useful for creating streams that apply multiple transforms in sequence:

Implementing a transform

At the heart of Confetti lies the TransformInterface interface. A correctly implemented transform can be used for both string-based, and streaming transformations.

A simple transform might look like the following:

The transform receives an arbitrary amount of data as a string, and returns an tuple (array) where the first element is the transformed data, the second element is the amount of data consumed in bytes (in this example, the data is always completely consumed), and the third element is any error that occurred.

This transform can now be utilized in several ways. To apply the transform to a string, simply call transform() with a boolean true for the $isEnd argument:

To use the transform as a React stream, create a new TransformStream and inject the transform.

Native stream filters

Transforms can also be used to implement native PHP stream filters, but PHP's stream filter system requires that each filter is implemented as an individual class. Confetti includes an abstract class that greatly simplifies implementing stream filters.

To create a stream filter simply extend from AbstractNativeStreamFilter, and implement the createTransform() method:

Once the filter is registered, it can be used like any other stream filter:

Note that the only way to detect a native stream filter failure is to check the length of data written. If the length is 0, it indicates an error:

Complex transforms

More complex transforms may not be able to consume data byte-by-byte. As an example, attempting to base64 decode each byte as it is received would result in invalid output. The correct data cannot be known until a full block of 4 base64 bytes is received. There's also the possibility of receiving bytes that are invalid for the base64 encoding scheme.

A base64 decode transform might be implemented like so:

This transform will now decode blocks of base64 data and append the result to the output buffer. The bufferSize() method suggests an appropriate buffer size for classes that consume this transform (in this case, 4 bytes - the size of a base64 block), and the call to AbstractTransform::blocksSize() ensures that data is only consumed in blocks of 4 bytes at a time. If an invalid byte is passed, or the data stream ends at an invalid number of bytes, an exception is returned as the third tuple element to indicate the error.

The context parameter

Transforms also have the ability to utilize the $context parameter. This parameter can be assigned any value, and is used as an arbitrary data store that is guaranteed to persist across the lifetime of the stream transformation. When the first call to transform() is made, the $context argument will be null. On subsequent calls, $context will contain whatever was previously assigned to the variable. This allows for advanced behavior, such as buffering.

As an example of the context's usage, consider a transform that produces an MD5 hash of the incoming data:

In this case, the $context parameter is used to store the hash context. The transform now functions as follows:


All versions of confetti with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
evenement/evenement Version >=1,<3
react/stream Version >=0.3,<0.5
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 eloquent/confetti contains the following files

Loading the files please wait ....