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

shakogele's avatar

Where to Set Global Variables in Laravel

Hello,

I have task scheduler which has an important task, so I want to set global variable for eg: $busy = true, till this task finishes its job.

where to set it?

0 likes
9 replies
Kemito's avatar

If you use queue for tasks you can set "priority" for them. I that task will be off the queue when it is finished and tasks with lower priority will execute after that. (correct me if i am wrong)

"Global variables" things i guess is bad. Setting "busy" state for something in config also sounds bad. Maybe if you can explain a bit more your situtation we can come up with best/better solution.

shakogele's avatar

For Example Balance Operation while crone (Scheduled Task ) is running.

shakogele's avatar

I think Config::set('busy', true) is ok and then check for state by config('busy')

Snapey's avatar

@oussama congratulations you are awarded the 'answered a 5 year old question' badge

Please or to participate in this conversation.