Back

Hey Laravel Developers

Out of all the features released recently (post Laracon US), one of my favourites is the defer() function.

The defer() function, as the name suggests, allows us to defer (postpone, in simple terms) the execution of a function or closure after the response is sent back to the client.

This is useful for minor operations that need to be performed in the background, where defining a Queue Job might be too much—for example, sending notifications.

Also, one cool thing that the defer() function does is that it verifies the response status code (2xx) to ensure it's successful before executing the closure.

image

59

  • No matching results...
  • Searching...

/ 1000