DEV Community

Discussion on: 4 Steps to Automate Repeated Tasks Using Laravel

Collapse
 
msamgan profile image
Mohammed Samgan Khan

i have a question, what's the logic behind creating command and creating a job with that command. you can directly write the requirements in the command and both command and job runs in background and you can schedule the command directly.

can you please provide any good logic over this.

Collapse
 
dog_smile_factory profile image
Dog Smile Factory

You're right, you can put your logic in the command class without creating a job. That makes a lot of sense to me.

The Laravel documentation has this suggestion:

"It is good practice to keep your console commands light and let them defer to application services to accomplish their tasks."

I based my approach on this.

Collapse
 
msamgan profile image
Mohammed Samgan Khan

ohhk. I personally prefer running commands as independent unit. no dependency on queue n all.