Often times it is required/necessary to defer or run in parallel some heavy processing or long running job that is triggered dynamically within your application. That's where the Queue service will come in handy.

The queue takes a minimum of 2 parameters. The first is the Class you want to use to do the work. You can pair the Class name with a "@" symbol to denote which method you wish to call on the Class specified. If no "@" symbol exists then a default method of work() will attempt to be called on the Class. The second parameter is the delay you wish to execute before the job begins being processed.

Optionally you can pass a 3rd parameter in the form of a string, a number, or an array. All of which are variables that will be passed to the job you specified in the first parameter.

$job = 'DB@query';
$delay = 0;
$var = 'CALL really_long_running_job()';


Queue::push('YourClass@yourJob', 10, [20, 'Johnny']);

$job = 'DB@query';
$userId = 439583;
$delay = 5;

$var = Array('
    UPDATE USER_FINANCE SET total_worth = 
        (SELECT SUM(udp.portfolio_value) FROM USER_DAILY_PORTFOILIO udp WHERE udp.user_id=?)
    WHERE user_id=?',


The jobs will start being processed after `delay` in parallel to the execution of the application request. Its completion and execution will not interfere with our applications request in any way.