Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Foks's avatar
Level 15

Laravel Package Development & Jobs

Hi!

I'm currently writing a package for Laravel, and I need to run a job in this package, but I'm not quite sure how I can do so, any ideas? I used this https://laravelpackageboilerplate.com/#/ boilerplate maker to create boilerplate for it.

Thanks in advance & Best regards Foks

0 likes
3 replies
bobbybouwmann's avatar
Level 88

What do you mean by run a job in this package? Do you want to provide a job that others can use? Or you actually want to dispatch a job (maybe even to the queue) automatically when someone calls a method of your package?

If that last one is the case, you need to include illuminate/bus as a dependency in your composer.json. After that, you can dispatch a job like so in your package

app(Dispatcher::class)->dispatch($job);

Of course, you can also dependency inject the Dispatcher class in the place where you call this method, but this should put you in the direct direction ;)

1 like
Foks's avatar
Level 15

Just to be sure, what is it that the app() method does?

Foks's avatar
Level 15

Nevermind, found out

Please or to participate in this conversation.