Yii 1.1: celery-yii

celery-yii is a YII extension to dispatch Celery (http://celeryproject.org) tasks

celery-yii is a Yii extension to dispatch Celery tasks.

It is a wrapper to celery-php, released under the same BSD license.

This extension is unrelated with the Yii AMQP extension. In case you don't actually need Celery, but just communicating via AMQP you may want to check that.


  • Yii 1.1 or above (tested on Yii 1.1.9)
  • Celery (tested on 2.5.5 and on 3.0.4)
  • PHP AMQP extension v1.0 or above (http://www.php.net/manual/en/amqp.setup.php)

celery-php is released within celery-yii

Be sure that both Celery and celery-php are installed and working.

This means:

  1. install Celery with

    pip install Celery
  2. install the PHP AMQP extension following these instructions. Note that celery-php contains a script to automatically do that.

  3. configure Celery as celery-php requires, i.e. adding the following configuration:


    Note: at the time of writing (2012-06-16) the documentation of celery-php reports a bad configuration parameter.


Download the package and decompress it in the protected/extensions directory.

Add the following configuration to protected/config/main.php:

    'celery' => array(
        'class' => 'ext.celery-yii.ECelery',
        // login, password and virtual host
        'login' => 'myuser',
        'password' => 'mypass',
        'vhost' => 'myvhost',
        // probably, you don't need to change host & port
        //'host' => 'localhost',
        //'port' => 5672,
        // almost surely, you don't need to change exchange & binding
        //'exchange' => 'celery',
        //'binding' => 'celery',

Send tasks to Celery:

$result = Yii::app()->celery->postTask('tasks.add', array(2,2));

You can either ignore $result if you just want to send async tasks to the backend, or use $result exactly as explained in celery-php, for instance:

    echo $result->result;



Be the first person to leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: ema
  • Category: Web Service
  • Votes: +1
  • Downloaded: 441 times
  • Created on: Jun 16, 2012
  • Last updated: Jan 3, 2013
  • Tags: celery, amqp, wrapper