Dave
Dave

Reputation: 21

Laravel 4 - how to use the package class as a queue worker

I have built my first Laravel 4 package.

I have used artisan to create the structure.

I need to use the package to process a queue (as the worker).

I am using the builtin Beanstalk queue and have it configured and I am able to add to the queue.

What is the correct syntax to add the correct path to the class that I would like to use to process the queue.

I can get this working if the class is saved here /app/controllers/TestClass.php ( beacuse this gets autoloaded)
Example:

Route::get('/addtoqueue', function()
{
    $message = "This is a test message";
    Queue::push('TestClass', array('message' => $message));
    return 'Added to Queue';
});

But what should I put in as the class in the queue if the class is in a package?
This file is in workbench: workbench\vendor\package\src\Vendor\Package

My package composer file contains

"autoload": {
    "psr-0": {
        "Qwickli\\Tika": "src/"
    }
},

Eg. Queue::push('vendor\package\TestClass', array('message' => $message));

When I run php artisan queue:listen it correctly picks up the items in the queue and but it does NOT find the class (in the package) that I would like to use process the queue.

For some reason the class is not being loaded (or autoloaded) and I don't know how to make that happen.

Thanks for all and any help

Upvotes: 0

Views: 587

Answers (1)

Luis Dalmolin
Luis Dalmolin

Reputation: 3486

Looks like your package classes are not been autoloaded.

Try to access your package folder, workbench/vendor/package and run a compsoer update. If your composer "autoload" settings are correct, this should work.

Upvotes: 0

Related Questions