The new defer() function in Laravel can be really useful when you need to perform an action that the user does not care about or don't want to wait for it. This can be useful when you are logging user interactions in an analytical database that takes a couple milliseconds or even seconds but you don't want your user to wait for that to finish (something they have no interest in) before they can navigate.

While you could use Laravel's Queue (Jobs) to achieve this but it's just a lot of cumbersome to create a job that just calls a single function or method. The defer() make it much more easier and faster to do it. That's what Laravel is about, easy & quick! A lot of reading, now let's jump to some examples.

continue reading on laraveleco.com

⚠️ This post links to an external website. ⚠️