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

webard's avatar
Level 1

Run code before or after every schedule command

Hello,

It is possible to run code after or before every command? Something like

Queue::before(function (JobProcessing $event) {
            // $event->connectionName
            // $event->job
            // $event->job->payload()
        });

I need to set some settings before every schedule and I can't find any informations about that.

0 likes
5 replies
webard's avatar
Level 1

I was afraid that this is the only solution. I know it, but it requires defining hooks per schedule, not globally.

Thank you for help.

1 like
martinbean's avatar

@webard This is a bit “X/Y Problem”. You’re asking about a solution.

Tell us the actual problem you’re trying to solve and there may be a better way to do what it is you’re trying to do.

1 like
Snapey's avatar

I don't understand why you are asking about schedule commands, but then showing code related to Queue?

Also, unless your configuration changes are atomic with the running the job itself, your method is fragile as soon as you have more than one worker

1 like

Please or to participate in this conversation.