The fact that PHP allows to start a new process in the background is game changer. defer, Concurrency facade and Cache::flexible are my favourite additions.
Really, really awesome example of deferring with + when blade helper. Definitely bookmarking this one to send to folks if they need help understanding the new features! 🙌
Josh, does the defer just launch another process? or does it send the response back to the browser and flush, but still require the browser be connected to be able to process? if you defer something that takes 10 seconds but you close the browser after 3 seconds will it still finish?
@felr1b oh I see. That makes a lot of sense. But does this deferred process block the next request from that same user's browser, supposing they make the next request before the "job" is done?
Laravel is still "alive" after the response is sent (to gather some information for logs, statistics, debug, etc. - search for tutorials related to the Response class and the response() helper). defer() just postpone closures to run at that point (after response is sent but Laravel is still loaded). There's no process fork involved, the closures passed to defer will run on the same process. There's no way to interrupt the process from "external" side as well (unless your closure itself intentionally watch for new requests or any signal that should interrupt it) and it doesn't block new requests from the same user (unless there's a limit on the number of concurrent requests/php processes on your environment which would result in a limitation to run simultaneous requests without defer() already).
The fact that PHP allows to start a new process in the background is game changer.
defer, Concurrency facade and Cache::flexible are my favourite additions.
Really, really awesome example of deferring with + when blade helper. Definitely bookmarking this one to send to folks if they need help understanding the new features! 🙌
Thank you Alex! I think the more people understand what defer() can do the better people can use it instead of throwing it on everything. 🫣
hey Josh , great content by the way , we need a livewire volt spa demo , thanx in advance
I'm new in Laravel and i love all you stuff... Good job!🔥🔥
Wow. Thank you so much. :)
I feel like I'm gonna use defer in one of my projects for activity logs. Like if I CRUD action happens, add it to the activity log.
Josh, does the defer just launch another process? or does it send the response back to the browser and flush, but still require the browser be connected to be able to process? if you defer something that takes 10 seconds but you close the browser after 3 seconds will it still finish?
I have been wondering about this and nobody is talking about this.
defer forks a new process and executes the closure. if you close the browser, the "job" will finish the same way (just like a queue job)
@felr1b oh I see. That makes a lot of sense.
But does this deferred process block the next request from that same user's browser, supposing they make the next request before the "job" is done?
Laravel is still "alive" after the response is sent (to gather some information for logs, statistics, debug, etc. - search for tutorials related to the Response class and the response() helper). defer() just postpone closures to run at that point (after response is sent but Laravel is still loaded). There's no process fork involved, the closures passed to defer will run on the same process. There's no way to interrupt the process from "external" side as well (unless your closure itself intentionally watch for new requests or any signal that should interrupt it) and it doesn't block new requests from the same user (unless there's a limit on the number of concurrent requests/php processes on your environment which would result in a limitation to run simultaneous requests without defer() already).
@@Xavi7th no, it doesnt block the next request. the "job" has no knowledge of the request context.
Win method 😀
Hey josh, i like your stuff, i would like to collab on a little idea can we chat?
after using laravel octane on my new projects
i think no need for this one