Replies: 2 comments 1 reply
-
Defer is just a fancy way of registering callbacks that are called upon termination inside a terminate method of a middleware. https://laravel.com/docs/11.x/middleware#terminable-middleware The solution you are proposing may have side effects. right away means you can't cancel if something later on fails. which might be expected. Also, I am wondering what particular setup you have that this won't work. Because terminable middleware have existed for a while now, and it works PHP 8.2 which is the minimum required version. |
Beta Was this translation helpful? Give feedback.
-
As mentioned in the Laravel docs, defer will only work with modern webservers
Executing right away shouldn't cause any problems, since the code that is executed after defer is not dependent on each other. |
Beta Was this translation helpful? Give feedback.
-
The defer function is great and works perfectly fine for most people. However for some people defer does not work due to their webserver/php manager.
It would be great if we could turn off defer using an ENV variable.
So for users that aren't using a modern php manager, they can have the task executed in the request rather than in the background
Something like
APP_DEFER_BACKGROUND=false
and then inside the defer() helper method
This simple addition would allow users that can't use the defer() method to turn it off without having to rewrite the entire application.
Beta Was this translation helpful? Give feedback.
All reactions