Execute Code After a Response is Returned?

  Рет қаралды 4,106

Laracasts

Laracasts

Күн бұрын

The latest version of Laravel 11 includes a useful defer() function that allows us to execute a bit of logic after the response has been returned to the user. For any relatively long-running task, this can be a game-changer. Let's review how it works!
Watch thousands of videos, track your progress, and participate in a massive Laravel community at Laracasts.com.
Laracasts: laracasts.com
Laracasts Twitter: / laracasts
Jeffrey Way Twitter: / jeffrey_way

Пікірлер: 22
@mrjoekneeland
@mrjoekneeland 17 сағат бұрын
I just learned 70 things in 14 minutes. Sweet new promo for laracasts at the end there. I'll be deferring tons. Thank you, Jeffrey and Laravel
@gherosh
@gherosh 21 сағат бұрын
wonder what issues timeouts causes with this defer 🤔
@antdonn
@antdonn 46 минут бұрын
i’m working on a project, right now, this is magic !!
@marcosaugustoschultzwutke6670
@marcosaugustoschultzwutke6670 23 сағат бұрын
Very good!!! I will use it in my applications. Thank you!
@dhawanj5592
@dhawanj5592 Күн бұрын
Jeff I will meet you once in life from India
@suikodevID
@suikodevID 11 сағат бұрын
So much knowledge to bite, delicious. but Where is the PHPStorm like usual
@juanflores.director
@juanflores.director 20 сағат бұрын
Nice lets try it out
@gidaban79
@gidaban79 8 сағат бұрын
Just wonder. How it will works with try catch, cashier and stripe ?
@ravenpk100
@ravenpk100 23 сағат бұрын
is defer a good use case for when deleting a row can cascade into deleting multiple rows like up to 10000 or a queue and job would be better for this?
@JohnnyBigodes
@JohnnyBigodes 23 сағат бұрын
If your project depends on it use the queue, otherwise use the defer. When something could go wrong and you need to retry, use always the queue.
@hlorofos
@hlorofos 22 сағат бұрын
I suppose there is no guarantee this defer code will keep working for a long time in cloud setups, like Vapor? Lambda executor could be terminated and your defer code could end up with partial result, resulting in corrupted data.
@renatofrota
@renatofrota 21 сағат бұрын
the "guarantee" is the same as if the code were executed without the defer. so if your time executing limitations is 30s and the task could not be completed as a regular code (before sending response to user) it won't execute as deferred code as well. this function is to be used to speed up navigation (do not make user wait for the small tasks to be completed before rendering page if these tasks will take just a few ms/secs and the probability of the successful completion is [near] 100%)
@josephuisso244
@josephuisso244 22 сағат бұрын
What will happen when the user navigates to another page will defer function still executed?
@renatofrota
@renatofrota 21 сағат бұрын
the user's request results is already sent and the process is now running standalone, it has no clue what the user is doing on their end, so it keeps running no matter what the user does - unless you intentionally somehow "watch" for new incoming requests in the closure code your pass to the defer() function.
@Wolfci
@Wolfci 23 сағат бұрын
It would be awesome when explaining when to use defer or jobs is to give examples like hey use defer for these scenarios that you would use in web development and use jobs for these examples could be short and simple explanation
@renatofrota
@renatofrota 21 сағат бұрын
let's say you have a list of items, paginated. and on render, you have to process/calculate something. if this is time consuming, you can defer a pre-calculation for all entries in the next/previous pages of the current page the user is viewing (and save them in cache). this way, when user clicks prev/next button, the page will load instantly (and the next/prev one starts processing in background and so on).
@LucianoTonet
@LucianoTonet 16 сағат бұрын
Using Cursor? 👀
@RaduStancaOnline
@RaduStancaOnline 22 сағат бұрын
Hold on a second, this looks like VS Code... 🤔🤔🤔🤔🤔
@CHSKnight
@CHSKnight 22 сағат бұрын
I believe it is.
@homamal289
@homamal289 4 сағат бұрын
Lol jeffery is dictionary like so much info in 13:59 amazing hope you give us an advanced laravel project like 30 day series
@samhk2222
@samhk2222 19 сағат бұрын
Wait a minute, what's that dump extension @ 1:07 ?
@tammyalemu
@tammyalemu 18 сағат бұрын
Laravel Herd
Eloquent's New Chaperone Method
9:57
Laracasts
Рет қаралды 8 М.
The Intermediate Developer Trap
18:39
Laracasts
Рет қаралды 20 М.
SHAPALAQ 6 серия / 3 часть #aminkavitaminka #aminak #aminokka #расулшоу
00:59
Аминка Витаминка
Рет қаралды 332 М.
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 8 МЛН
ПРИКОЛЫ НАД БРАТОМ #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 50 МЛН
Using Generics with PHP
25:55
Laracasts
Рет қаралды 11 М.
Here's What You Missed at Laracon
12:21
Laracasts
Рет қаралды 120
BEWARE these Laravel attributes | Real World Laravel
19:10
Sam Lewis
Рет қаралды 3,7 М.
Str::markdown() is More Powerful Than You Think
11:04
Laracasts
Рет қаралды 3,5 М.
Dive Deeper with Actions
12:34
Laracasts
Рет қаралды 3,9 М.
Let's Build a SaaS in Laravel
2:38
Laracasts
Рет қаралды 8 М.
PhpStorm for Laravel Developers - 3 Hour Full MasterClass
2:35:29
Popping Over with Popovers
31:08
Laracasts
Рет қаралды 2 М.
SHAPALAQ 6 серия / 3 часть #aminkavitaminka #aminak #aminokka #расулшоу
00:59
Аминка Витаминка
Рет қаралды 332 М.