Search code examples
phpsqlubuntularavellaravel-3

Class not found with Laravel 3 and Composer


I am attempting to use the php-resque composer package via artisan. I believe Laravel is v3.2.7. When running the command php artisan queue I get the error:

Error

PHP Fatal error:  Class 'Resque' not found in /var/www/dev/application/tasks/queue.php on line 20

Fatal error: Class 'Resque' not found in /var/www/dev/application/tasks/queue.php on line 20

What seems to be the problem here? The php-resque package appears to have been installed to the vendor directory...

PHP (queue.php)

class Queue_Task
{
    public function run()
    {

        // Autoload composer vendors.
        require path('composer').DS.'autoload.php';

        // You can pass arguments into the worker as payload
        $args = array('name' => 'John Smith');
        Resque::enqueue('testqueue', 'ExampleWorker', $args);

        echo "Resque job queued.\n";
        return;
    }
}

public/index.php

// --------------------------------------------------------------
// Tick... Tock... Tick... Tock...
// --------------------------------------------------------------
define('LARAVEL_START', microtime(true));

// --------------------------------------------------------------
// Indicate that the request is from the web.
// --------------------------------------------------------------
$web = true;

// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require '../paths.php';

// --------------------------------------------------------------
// Autoload composer vendors.
// --------------------------------------------------------------
require path('composer').'autoload.php';

// --------------------------------------------------------------
// Unset the temporary web variable.
// --------------------------------------------------------------
unset($web);

// --------------------------------------------------------------
// Launch Laravel.
// --------------------------------------------------------------
require path('sys').'laravel.php';

// --------------------------------------------------------------
// Autoload composer vendors.
// --------------------------------------------------------------
require path('composer').DS.'autoload.php';

paths.php snippet

// --------------------------------------------------------------
// The path to the composer vendors directory.
// --------------------------------------------------------------
$paths['composer'] = 'vendor';

Solution

  • Youre missing a DIRECTORY_SEPARATOR for your composer path.