Download the PHP package ulabox/gearman-bundle without Composer

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

GearmanBundle

The bundle provides an interface between symfony2 projects and Gearman Job Server.

Quick installation

Require the bundle in your composer.json file:

Run composer update command:

Now add the Bundle to your Kernel:

Gearman dependency

To install Gearman Job Server for Debain/Ubuntu Package using the following commands:

Once the job server has been installed, can be started by running:

Install the Gearman driver

To install Gearman driver using the following commands:

Now we just need to enable the module. Edit your /etc/php5/conf.d/gearman.ini file and add the line:

Configuration

By default, the bundle doesn't need any configuration, but you can configure it editing your config.yml:

Writing Simple Worker

For a bundle located at src/Acme/DemoBundle, the worker classes by default should live inside src/Acme/DemoBundle/Gearman/Worker. We can create a simple worker as shown below:

Note how the the worker class is marked with @Worker() annotation and each method considered as a job is also marked with the @Job() annotation.

Executing the job

Once your job have been written, can be run in two ways:

By code:

To view the result open a console and run the command:

Then run the code above.

By the command line:

Open the first console and run:

Now open another console and run:

The commands come with a few options, you can see more details in the commands section.

Annotations

Worker annotations
Client annotations
Job annotations

Writing Simple Client

For a bundle located at src/Acme/DemoBundle, the client classes by default should live inside src/Acme/DemoBundle/Gearman/Client. The client class by default is associated with the Worker class with the same name, for example, the AcmeClient will be associated with AcmeWorker:

Note how the the client class has a callback methods to be notified when the worker do the job, but it only makes sense when the job is executing with doNormalJob method.

Executing the job through client

Once your job have been written, can be run in two ways:

By code:

To view the result open a console and run the command:

Then run the code above.

By the command line:

Open the first console and run:

Now open another console and run:

Run Tasks

Add a task to be run in parallel with other tasks is very simple. Adding to the previous worker a new job:

Once your job have been written, can be run as show below:

To view the result open a console and run the command:

Then run the code above.

Commands

Show all workers registered:

Execute a job:

Execute a worker:

Asynchronous Events

Exploiting the potential of Gearman Job Server, we have introduced a new EventDispatcherAsync that replaces the default symfony EventDispatcher, the new dispatcher has a new method called dispatchAsync that sends the event to the gearman queue, gearman processes it and sends it back to the php application, which finally reconstructs the event and run it asynchronously.

Configuration

To use asynchronous events the first thing to do is import the routing.yml file of the gearman bundle.

And add the route in the access control from your security.yml file.

Enable the asynchronous event dispatcher in your config.yml.

The EventWorker is responsible for processing the event and send it back to the app. This worker needs to generate a url from the command line, and this requires us setup the request context globally.

Now that everything is configured the following step is run the EventWorker in the command line

The EventWorker should always be running, so we recommend using a tool such as the supervisor to ensure that the worker is always running.

Writing an async Event

An async Event is a simple event with the only difference that must implement the interface Ulabox\Bundle\GearmanBundle\Dispatcher\AsyncEventInterface. Here we show a small example:

Note that the class implements the two AsyncEventInterface methods (getArguments, setArguments), these are used internally to reconstruct the event.

Create an Event Listener

Now that the class is created, you just need to register it as a service:

Dispatch the Event

The dispatchAsync() method begins the process and notifies asynchronously all listeners of the given event


All versions of gearman-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
symfony/framework-bundle Version ~2.3
doctrine/common Version ~2.2
jms/metadata Version >=0.11
jms/serializer-bundle Version 0.12.*@dev
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 ulabox/gearman-bundle contains the following files

Loading the files please wait ....