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

ahoi's avatar
Level 5

Run command inside a job

Hello everybody,

I got a command that performs some heavy machinery (runs multiple docker-container and creates a new model instance from the output).

This works fine (I mean: Really, fine. Laravel is great! :-D ).

Now I would like to create a possibility to create those jobs using the API.

Now what I am planning to do:

  • Inside my API-Controller: Dispatch a job
  • Inside the job: Run the command

Now my question: Is it even possible to run commands from old-fashioned controllers? Or is it even a good idea?

0 likes
4 replies
Snapey's avatar

You can run a command from anywhere

I would probably question if you should

Since when have controllers been 'old fashioned'

ahoi's avatar
Level 5

Hi @snapey ,

correct - this is the question. Is it a good idea to run a command from the job or would it be a better idea to move the handling-part and call it:

  • A: From the command
  • B: From the controller

"Old-fashioned", because I am using it for handling HTTP-request without "fancy shell execution", which I am learning with Laravel at the moment ;-)

Snapey's avatar

my concern is your description of 'heavy lifting'

If its easy to hit an endpoint and have this heavy task launched, what happens if that endpoint is hit multiple times in quick succession?

Without control, could your server go down because its trying to fire up multiple docker instances?

Please or to participate in this conversation.