LazyCollections and PHP Generators. How to Use Them in Practice

4,365 views

Просто о Laravel. CutCode

Published on Oct 23, 2023
About :

This video is about PHP generators and LazyCollection. We'll use an example to see how generators can optimize memory usage. Let's pay attention to where generators are used in laravel, how convenient it is for us to use them and when. #LazyCollections#PHP#laravel#cutcode --------------------------------------------------------------------------------- ????????????‍???? How about upgrading your skills with our web development training video courses? Go to my website ???? https://learn.cutcode.dev/?utm_source=yt ❗️❗️❗️Join our community on Telegram - they'll help you with advice and a lot of interesting things - https://goo.su/dsGP7PI --------------------------------------------------------------------------------- I welcome all laravel fans to the CutCode channel! Today we'll talk about PHP generators. About this scary word vield and again we will implement an example that everyone does in training videos and articles. With a huge array, which is formed by the Range function. But friends, I am deceiving you and in fact we will not do this. There are already thousands of videos about generators and their wonderful effect on memory. All of them are within the framework of the example with an array built on the Range function. The same goes for articles and the documentation itself. And you have all seen it many times already. And for those who have not seen it, I recommend watching or reading. But I think in the end after studying you will be satisfied - you understood everything. But where to apply, when to apply you still do not know. And after a couple of hours you will forget about them altogether. Therefore, we will discuss their essence a little, literally a couple of sentences, but we will talk about a specific application. Where they are used in laravel, how it is convenient for us to use them and when. Well, let's go! Friends, a problem. Let's say we need to interact with models and, for example, calculate something based on them. And we need models with casts and other things. We have an entity - we take all the records - in this case there are 10k records. We do the process itself somewhere in a console command on a schedule and calculate something in some entity. As a result, such a request will form a collection of ten thousand models at the output. Pay attention to how much memory we needed for this - as much as 30 megabytes. And here there are only 10k records. If we talk about SQL queries and query builder, then the cursor method can come to our aid. Let's use it instead of All, and then delve into the method itself. And here we will see that it works just on the generator, here is our favorite vield. And it is not just a collection that helps it, but a Lazy collection. --------------------------------------------------------------------------------- ???? share this video with your friends: • LazyCollections and PHP generators. How... ???? subscribe to the YouTube channel: https://www.youtube.com/c/CutCodeRu?s... ???? Laravel course from scratch: • Laravel 8 course training from scratch. Be... NAMENAMENAME --------------------------------------------------------------------------------- ???? our website: https://cutcode.dev/?utm_source=yt ???? Our telegram channel: https://t.me/laravel_cutcode

Trend Videos
3:11
49,566,928 views   10 days ago
6:18
178,487 views   3 days ago
3:22
635,579 views   4 days ago
6:18
178,487 views   3 days ago
19:27
688,103 views   2 days ago
9:37
1,155,450 views   13 days ago
29:19
642,453 views   1 day ago
8:05
2,489,245 views   6 days ago
29:19
642,453 views   1 day ago
58:52
660,979 views   9 days ago
8:05
2,489,245 views   6 days ago
Google AdSense
336 x 280
Up Next
1:01:13
37:04
50:49
1:07:12
PAW Patrol Nederlands - Officiële Kanaal
239,079 views
9 months ago
1:01:34
PAW Patrol Nederlands - Officiële Kanaal
928,217 views
1 year ago
1:13:53
Nickelodeon Nederlands
16,390 views
12 days ago
1:23:07
1:29:21
3:40:58
1:28:03
1:07:35
1:02:58
29:13
Nick Jr. Nederlands
196,309 views
1 year ago
1:12:06
Nickelodeon Nederlands
129,760 views
11 months ago
1:00:23
55:09
53:35
ARTEde
447,377 views
4 months ago
43:16
Terra X History
1,849,655 views
3 years ago
1:49:17
TU Wien Academy for Continuing Education
45,941 views
2 years ago
51:56
Irgendwas mit ARTE und Kultur
288,355 views
5 months ago
43:38
Terra X History
741,176 views
2 weeks ago
43:39
ARTE Family DE
51,839 views
8 days ago
1:38:15
Terra X Lesch & Co
2,631,720 views
Streamed 1 year ago
43:09
Terra X History
579,475 views
3 months ago
1:21:49
Copernicus
615,606 views
Streamed 2 years ago
55:45
22:43
28:45
43:38
Terra X Lesch & Co
605,062 views
7 months ago
Google AdSense
336 x 280

fetery.com. Copyright 2024