Dispatch Jobs in Laravel Tinker AKA Why Laravel Tinker does not dispatch Jobs?
;1 suffix after the dispatch command:
Dispatching Jobs through Laravel Tinker
If you want to dispatch a job into the queue through Laravel Artisan Tinker, you’ll open the Tinker and write:
And see the job is actually is not dispatched. If you run the command again, you’ll see the same response but the job is dispatched into the queue only once.
Why Laravel Tinker did not Dispatch the Job for the First Time?
The problem is that Laravel Tinker keeps the generated
PendingDispatch objects in memory for the user to use in subsequent commands. When this object is destroyed, it actually dispatches the job.
To solve this job in the very right way, you can dispatch the job through Laravel’s
To solve this quickly and hacky:
By adding a
;1 suffix, Tinker will not keep
PendingDispatch objects in memory and dispatches jobs.