When you need to dispatch job from tinker, the normal command which is
App\Jobs\YourJob::dispatch();
would not work in tinker because dispatch helper function depends on garbage collection. Hence to dispatch a job from tinker, use any of the following commands
\Bus::dispatch(new App\Jobs\YourJob($someArgument));
\Queue::push(new App\Jobs\YourJob($someArgument));
Top comments (6)
nice thx!
Thanks.
Any way to add one of these to a specific queue? Using onQueue like we do in standard Laravel code throws an error:
\Bus::dispatch(new \App\Jobs\My Job())->onQueue('long-running-queue')
PHP Error: Call to a member function onQueue() on string in /home/my/siteeval()'d code on line 1
Late answer, but the Bus::dispatch method determines the queue from the command/job itself
You just saved me from some more frustrated hours. Thanks!
Glad that this is still here! I forgot what is was since the last time. Thanks a lot!