Download the PHP package etouches/phplumber without Composer
On this page you can find all versions of the php package etouches/phplumber. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download etouches/phplumber
More information about etouches/phplumber
Files in etouches/phplumber
Package phplumber
Short Description Pipelining library which allows a mix of asynchronous and synchronous processes.
License MIT
Informations about the package phplumber
Phplumber
Phplumber is a very simple pipelining library for PHP which allows a mix of asynchronous and synchronous processes. Use it to break a large process into multiple steps using a queue and multi-processing. Phplumber contains no hard-coded dependencies and can be backed by any queue setup and any storage mechanism.
Requirements
- PHP 5.3+
- A queue, such as RabbitMQ or Redis
- Storage, such as a relational database table or Redis
Example
Let's take creating and filling a database as an example. It takes multiple steps and some can be done concurrently.
- Create database (one process)
- Create and populate tables (one process per table)
- Create views dependent on multiple tables (one process, dependent on all tables existing)
First we would define our processes. Sequential steps extend Process
. A step that can run multiple times with
different data extends MultiProcess
.
Then we define the sequence of processes.
We can now kick off the process sequence.
See the examples
directory for complete, working demos.
Getting Started
- Implement
StorageInterface
. This will hold semaphore data. Appropriate storage engines include any relational database, nosql, or key-value stores such as Redis. - Extend the
Queue
class to integrate with a queue system. Appropriate queue engines include Redis and RabbitMQ. - Write each process as a class that extends
Process
(for synchronous) orMultiProcess
(for asynchronous). - Implement
ProcessFactoryInterface
. This will create each instance ofProcessInterface
, allowing you to set up your processes with any prerequisites, such as a database connection or configuration options. - Put the processes together by extending
ProcessList
. - Implement a worker daemon which instantiates your
Queue
implementation and callsconsume()
to listen for incoming messages. Each message is to invoke a single part of a multi-process. Run multiple workers to execute processes concurrently. - Choose a place in your system to start the entire workflow, instantiate your
ProcessList
, and callprocess()
, passing it the initial payload.