Download the PHP package virge/graph without Composer
On this page you can find all versions of the php package virge/graph. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package graph
Short Description PHP Workflow Service powered by RabbitMQ via Virge::Graphite
License MIT
Informations about the package graph
Virge::Graph
Virge::Graph is a simple workflow framework to provide scalable queue backed job processing.
Virge::Graph requires RabbitMQ (http://www.rabbitmq.com/) , and a MySQL Database (https://www.mysql.com/).
Virge::Graph uses the Virge::Graphite queue library to handle all of the workers, and scaling. https://github.com/siosphere/virge-graphite
Getting Started
You will need to setup a RabbitMQ Server, and a MySQL Server. Both can be setup easily using http://www.docker.com/
You will need to include the virge/graph package in your project:
You will also need to create a Virge::Reactor and setup some configuration files.
If starting a project from scratch, you can use the virge/project
Which will setup the Reactor for you.
To add to existing projects, it is recommended to make a sub-folder to house the virge configuration files and reactor.
Reactor
The reactor will automatically load all of the configuration files, and register the services needed into Virge.
You will also need to setup / create two configuration files in config/, You can copy these files from the examples directory
database.php
queue.php
You will also need an entry point to run the reactor and process your queues, there is a lightweight admin tool included called "vadmin" that you can copy from the examples directory, or create a new file
vadmin.php
We will also need to create and setup our workflows file, this only needs to contain the definitions for our workflows, the workflow class can be autoloaded by composer see https://getcomposer.org/doc/
workflows.php
The reactor and workflows must be included in your app anywhere you'd like to push onto a workflow. They are automatically included from the resources dir if using a virge/project.
Simple Mode
Virge::Graph has a simple workflow mode, that allows 1 queue to process your workflow. This doesn't allow you to individually scale out individual tasks, but does make it simpler to setup.
Defining a Workflow
A workflow is a class that defines a series of tasks, and their dependencies, as well as their life-cycle callbacks.
A task can be a Closure, or it can be a class that has a "run" method.
And when defining, simply pass in the className
Pushing a job onto a workflow
A Job is a Virge\Graph\Component\Workflow\Job object. You can setup initial data by using the "setData" function. You can setup complex data in setData, but be aware it is serialized and pushed onto multiple queues, so it is unwise to put large amounts of data, and better to pass simple data, and load in the data on each worker.
Working the Queue
You must setup at least 1 worker to work the default virge:graph queue, this queue handles scheduling of tasks, life-cycle events, updating tasks progress, and syncing their results with the database.
On Advanced workflows, each task will be queued to it's own queue, to allow horizontal scalability.