Installation

Requirements

RECOMMENDATION Installing PhpRedis is strongly recommended, but if you can't, it will fallback to Redisent, another Redis API for php, shipped with the plugin.


Installation

Add CakeResque as a dependency in your composer.json

{
    "require": {
        ... your other dependency
        "kamisama/cake-resque": ">=4.1.0"
    }
}

then run composer install.

If your application does not contain a composer.json yet, run the following command in your shell

cd path/to/your/app
curl -s https://getcomposer.org/installer | php
php composer.phar require --no-update kamisama/cake-resque:4.1.0
php composer.phar config vendor-dir Vendor
php composer.phar install

That will take care of installing composer, generating the composer.json, and installing the plugin.


Configuration

Load the plugin into CakePHP

  • Load the Plugin with its default configuration in your app/Config/bootstrap.php
CakePlugin::load(array( # or CakePlugin::loadAll(array(
    'CakeResque' => array('bootstrap' => true)
));
  • Create the AppShell.php file in app/Console/Command, if it doesn't exist

  • Add the following method to AppShell.php

public function perform() {
    $this->initialize();
    $this->loadTasks();
    return $this->runCommand($this->args[0], $this->args);
}
Final AppShell.php
<?php
App::uses('AppModel', 'Model');
class AppShell extends Shell
{
    public function perform()
    {
        $this->initialize();
        $this->loadTasks();
        $this->{array_shift($this->args)}();
    }
}


  • If not already done, load composer autoloader into your application, by adding the following line at the end of app/Config/core.php
require_once dirname(__DIR__) . '/Vendor/autoload.php';

Configure CakeResque

All settings are well documented inside the plugin config.php file.

It's recommended that you don't edit the default config file, but create another one overriding the default settings.

Example

# app/Config/cakeresque_config.php
Configure::write('CakeResque.Redis.host', 'mylocalhost');

Load the plugin with

CakePlugin::load(array( # or CakePlugin::loadAll(array(
    'CakeResque' => array('bootstrap' => array(
        'bootstrap_config',
        '../../../Config/cakeresque_config', # Path to your own config file
        'bootstrap')
    )
));

In this example, the config file is app/Config/cakeresque_config.php. You don't have to include or require the original Config file.
Keeping your own setting in your own file, outside of the plugin directory is a good pratice, as it allows the smoothest plugin update experience.


Update

Just run

cd path/to/your/app

php composer.phar update
# Or
composer update

DebugKit

You can view job queuing log by installing the DebugKitEx panels.

DebugKit Resque panel