Тёмный

SOLID Principles in Laravel: 5 Examples (+ New Course!) 

Laravel Daily
Подписаться 141 тыс.
Просмотров 72 тыс.
50% 1

Get the full course "SOLID Code in Laravel" laraveldaily.com/course/solid...
In this longer video, I will show examples of SOLID principles, specifically in Laravel projects.
00:00 Intro and New Course
01:53 S: Single Responsibility Principle
04:29 O: Open-Closed Principle
07:08 L: Liskov Substitution Principle
11:11 I: Interface Segregation Principle
13:35 D: Dependency Inversion Principle
15:40 SOLID in Everyday Life
- - - - -
Support the channel by checking out our products:
- Enroll in my Laravel courses: laraveldaily.com/courses
- Subscribe to my weekly newsletter: bit.ly/laravel-newsletter

Хобби

Опубликовано:

 

13 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 96   
@giacomogaravaglia6742
@giacomogaravaglia6742 2 года назад
"I'm not in the mood to fix it." Everyone in their programming life has said it at least once!
@LaravelDaily
@LaravelDaily 2 года назад
It's just that I know that I'm in the flow of shooting video, and if I break it to spend 15 minutes on diving into PhpStorm configs, the video quality will get worse when I get back :)
@SamBennettWebDeveloper
@SamBennettWebDeveloper 2 года назад
@@LaravelDaily To fix some of the warnings. Instead of doing Model::all() and Model::where() always start with Model::query() i.e. Model::query()->where()
@LaravelDaily
@LaravelDaily 2 года назад
Yes, that may help with some Eloquent methods (also Laravel IDE Helper may help), but in that particular case, it was a general screw up with PhpStorm .idea settings, it didn't recognize even the base Controller in Laravel.
@ran_velo
@ran_velo 2 года назад
@@LaravelDaily Make a t-shirt with the phrase
@lynic-0091
@lynic-0091 2 года назад
In only 21 minutes you're teaching something which looked so difficult and intimidating to me at first, and now I completely understand what SOLID means. You're one hell of a teacher. Thanks for the free content!
@daniyarbaizhaksynov9230
@daniyarbaizhaksynov9230 2 года назад
The presentation of information is so simple and extensive that you are surprised at the skill of the narrator. True artisan)
@assanesambagueye4132
@assanesambagueye4132 2 года назад
Kinda Self-taught here! I had lots of duplicate code on my project, in views, controllers, livewire components, etc. Now I'm applying what I've learned from you (services, form requests...) and it makes maintainability and changes so much easier! Thank you all the way from Senegal :D
@christiansenmarcus
@christiansenmarcus 11 месяцев назад
Best description of SOLID in Laravel I've seen. Thank you.
@yhaelopez
@yhaelopez 2 года назад
I loved the way you explained SOLID. Finally, I can say that I'm starting to understand it.
@demiurgich
@demiurgich 2 года назад
Thank you, Povilas! You are perfect simplifier! Even I could not explain those principles in more understandable way.
@nirajgautam403
@nirajgautam403 2 года назад
You are my inspiration of upgrading my coding standards daily. Thank you
@marcoantonio7634
@marcoantonio7634 5 месяцев назад
I love how you explain the code, it really expands my knowledge
@L-A-O-S
@L-A-O-S 2 года назад
I always wanted to learn more about SOLID. Thanks!
@TheHBR99
@TheHBR99 2 года назад
Finally you made it easily understandable to me. Thanks a lot!
@i_m_denny_
@i_m_denny_ Год назад
Hey Povilas, Brilliant Content! Thank you for sharing your knowledge.
@codewithfongoh
@codewithfongoh Год назад
Thank you so much. Always awesome learning from your channel. I look forward to making videos as awesome as yours in the near future. For now, i stick with the basic ones lol
@JigarDhulla
@JigarDhulla 2 года назад
Thank you. Agree it is not easy to find SOLID examples in PHP with real life examples. Thanks for this and the course.
@user-zh2oz9fe4m
@user-zh2oz9fe4m 10 месяцев назад
I'm very grateful for your extremely useful videos!
@Diego-eb9we
@Diego-eb9we Год назад
Best teacher ever. Thank you!
@RehmanKhan-zv2rl
@RehmanKhan-zv2rl 2 года назад
Sir! great effort, its very helpful, thanks.
@ironspider9026
@ironspider9026 2 года назад
Very well explained the information here is pure gold. Thanks for sharing wish I could give 1k likes to the video.
@GergelyCsermely
@GergelyCsermely 2 года назад
Thanks, I'm happy to leran sometning new again :)
@okz9908
@okz9908 2 года назад
you really just doing a great explanations in your RU-vid channel
@eugenelviv7490
@eugenelviv7490 Год назад
This is the best explanation I met
@phil86_
@phil86_ 2 года назад
Great tutorial as always
@ghostza1209
@ghostza1209 Год назад
Thanks i’ll enroll your corse shortly
@phanta5m
@phanta5m 2 года назад
finally i can understand what is open close principle benefit. the codeis extended, no need to import or send another data to view again. thanks
@belce1982
@belce1982 2 года назад
Thanks as always!
@zohrehbabaei5467
@zohrehbabaei5467 10 месяцев назад
Thank you so much 🙏🙏
@TahsinAbrar
@TahsinAbrar 2 года назад
Loved the "SOLID in Everyday Life" part. Because, we can learn SOLID from different sources. But very few told the thing that you told in this part - The real life dilemma. We actually need to talk to our future self. And also need to think about the next developer(s) who will work on this code.
@SilverPaladin
@SilverPaladin 2 года назад
You might even say "Sometimes reality gets in the way of our idealism"
@bmtamim7818
@bmtamim7818 2 года назад
I just waiting for that. I was very curious to know how SOLID will work with LARAVEL. Because, I saw that the D of SOLID always break when we write code.. Thanks a lot, sir😍
@zieddams
@zieddams 2 года назад
thank you for this content
@ZamirMubashir
@ZamirMubashir Год назад
Thanks!!
@MahmoudMohsab
@MahmoudMohsab 2 года назад
great job as usual
@unitaxi1644
@unitaxi1644 2 года назад
Very usefully and easy to understand! Thank you! Please make a video about Laravel websockets (Pusher). It will be great job!
@LaravelDaily
@LaravelDaily 2 года назад
I will create a full course about it, later in 2021.
@user-xz7vy5bz1x
@user-xz7vy5bz1x 8 месяцев назад
Хороший английский, превосходное видео! Спаасибо
@bebebeb6498
@bebebeb6498 2 года назад
Thx 👍
@salahuddinayubi3906
@salahuddinayubi3906 2 года назад
you are my inspiration. please shoot a video on following topics. 1) The common PHP or web server exploits and their solutions. 2) Integration of multiple data sources and databases into one system. Thanks in advance.
@LaravelDaily
@LaravelDaily 2 года назад
Sorry, those topics are not in plans, too narrow edge topics for my audience.
@salahuddinayubi3906
@salahuddinayubi3906 2 года назад
you are genius
@mohamedruzaik3483
@mohamedruzaik3483 2 года назад
Sublime is perfect for showing code
@llBestBoyll
@llBestBoyll 2 года назад
PHP ❤️💪🏼🔥🔥🔥
@valencefredrick7495
@valencefredrick7495 Год назад
You talked about considering what might change in the future when choosing to implement the SOLID Principles. Doesn't that Violate the YAGN Extreme Programming Principle?
@bremg9185
@bremg9185 Год назад
Nice! But how many methods/resposabilities does that controller have?
@TheMarcelitto
@TheMarcelitto 2 года назад
Excelent! Thank you for all you videos, I'm learning a lot, i have a doubt when you typehint the return type of a function, that function must return something always, if returns null, an exception occurred, and sometimes that null value it's fine, how should I proceed in that case?
@LaravelDaily
@LaravelDaily 2 года назад
You may specify a few types to return: type, null or exception
@nerjuz
@nerjuz 2 года назад
Readable, maintainable and TESTABLE!
@LaravelDaily
@LaravelDaily 2 года назад
I think I need to shoot a separate video on how to make code testable. Thanks for the suggestion, added to the to-do list.
@mistersimeeec
@mistersimeeec 2 года назад
Would be interested to see more combining I and D. E.g. if you're separating your interface concerns as you did in your example, but the method typehinting actually requires the combination of those interfaces how would you approach that? Would you have to create another interface which implements the two ones we need and just typehint that? Cheers.
@LaravelDaily
@LaravelDaily 2 года назад
Good question. I guess in that case, if the situation requires one or another class, it would not go into parameter anymore, bue would rather be resolved inside the function itself.
@alexaverkiyev9099
@alexaverkiyev9099 2 года назад
From my experience: Always typehint variables and typehint returns. The return should not be mixed. If working with 3rd party services - always use interfaces. Even when working with services like image upload ('Spatie medialibrary' for example), one day you might swap to something else. Better to create an interface and a class that controls that upload (in that case a class that talks to spatie medialibrary).
@LaravelDaily
@LaravelDaily 2 года назад
I partly agree in theory, but in practice - how many times did you ACTUALLY, in real-life, had to swap media library (or similar example) to something else? In my experience, even if you do swap with something else, you usually have a different interface, because that other tool has different set of features or works in a different way. So, using interfaces BEFORE you have at least two implementations of that interface, in my opinion, is overengineering and premature optimization.
@kaisertushar7554
@kaisertushar7554 2 года назад
Thanks for awesome courses. Do you have any plan making a course for Laravel Octane?
@LaravelDaily
@LaravelDaily 2 года назад
No, I haven't used it myself, and not planning to.
@barktwain
@barktwain Год назад
I liked developing with sublime, but phpstorm is far better! :)
@butcherfirewaters
@butcherfirewaters 2 года назад
this principle asked me when i apply position - Junior Laravel developer )
@LaravelDaily
@LaravelDaily 2 года назад
And how did it go for you? :)
@butcherfirewaters
@butcherfirewaters 2 года назад
​@@LaravelDaily I knew only 1 principle and how to answer it and use it - single responsabilites ) Other responsabilities I missed(passed) And I didn't get a job ;)
@LaravelDaily
@LaravelDaily 2 года назад
I don't think that missing principle was the main reason that you didn't get the job :) At least, that's not how I would hire/choose a junior :)
@butcherfirewaters
@butcherfirewaters 2 года назад
@@LaravelDaily ))) Thanks for supporting and for your videos. It's really helping a lot of people!
@bumblebity2902
@bumblebity2902 2 года назад
@@LaravelDaily Sadly, it could be. Maybe company works with large scale projects where this pricinple is applied. Junior developers could be easily confused with advanced code structure.
@amra-dev
@amra-dev 2 года назад
When you code, constantly ask yourself two questions: Question 1: Who and How will they use that code in the future? Question 2: What may change in the future?
@ramziddinrustamov5221
@ramziddinrustamov5221 10 месяцев назад
😊
@davenegasn
@davenegasn Год назад
Why in the Single responsibility principle you use a service to handle the create logic and not the model?, shouldn't a method inside the model be enough?
2 года назад
shouldn't ReportDownloadInterface extends ReportDataInterface intead of implementing both?
@jimishukurow2286
@jimishukurow2286 2 года назад
Royal like from me. I use VScode.
@noli-timere-crede-tantum
@noli-timere-crede-tantum Год назад
8:56 Wouldn't the better solution to adding that new parameter in only one of the classes be to inject that param via the class constructor? This would retain LSP, as well as O/C.
@dfordemo981
@dfordemo981 2 года назад
is there any package/class that can convert pdf into proper html/css,? i mean the pdf is resumes, and properly written documents only, and we want to convert them into html/css's? 😁
@RizkheyG
@RizkheyG 2 года назад
Up till now I always treat 1 module in 1 class(ex: for Creating, updating and deleting with bunch of private methods for everything else that shouldn't accessed from outside the class for example for repeating task inside the class) until my team ask me to implement single responsibility principle and I have to separate my single class to let's say 3-5 separated class. The problem is, how to make sure someone else(maybe new dev in my team), not accessing "the other class" that previously/originally a private method in my original class?
@PetarVasilevX
@PetarVasilevX 2 года назад
I didn't quite understand the Liskov substitution principle. Like what exactly is the problem there? Any other examples?
@fcolecumberri
@fcolecumberri 2 года назад
Which pages would you recommend to search laravel jobs
@LaravelDaily
@LaravelDaily 2 года назад
larajobs.com
@phpcoding9282
@phpcoding9282 2 года назад
I'm a bit confused ... under the I principle you replaced ReportInterface with ReportDataInterface and ReportDownloadInterface .... but then later in the D example you have ReportInterface $report - how does this work with the Data and Download interfaces you created in the previous section? Could I do ReportDataInterface AND ReportDownloadInterface $report ? Because the report must have the two methods getData() and download() to work in the controller. Hope that makes sense 👍
@LaravelDaily
@LaravelDaily 2 года назад
That's a bit of misleading example, I agree. In real life, if you separate two interfaces, then likely you won't use those interfaces as dependency in methods at all.
@phpcoding9282
@phpcoding9282 2 года назад
@@LaravelDaily Thanks, I do find sometimes with Solid I dig my self into a corner with it. More of an art than a set of rules maybe.
@abdulrehmandar8541
@abdulrehmandar8541 2 года назад
Hi Povilas. I need suggestion. I'm using spatie media library for storing images. but how to give collection url to api user. How mobile app developer get media urls. Thank you
@LaravelDaily
@LaravelDaily 2 года назад
Read the package documentation for it, I remember they do have Media Collections or something like that.
@abdulrehmandar8541
@abdulrehmandar8541 2 года назад
@@LaravelDaily yes for web I can use media but for mobile app I don't think there's anything. I think I have to get get media my self and send it into response.
@goichikawasoe163
@goichikawasoe163 2 года назад
Excuse me, what would you recomend to use with laravel? Vue.js or react.js?
@LaravelDaily
@LaravelDaily 2 года назад
Vue is much more popular, with more examples.
@goichikawasoe163
@goichikawasoe163 2 года назад
@@LaravelDaily i see, thank you, ita just that im trying to update my knowledge in laravel, because last time i was using it with jquery, but in this days, thats way obsolete u.u, well now i know, thank you again :)
@romanperegudov2723
@romanperegudov2723 2 года назад
In example when you use injected InvoceService in action you violation D principle:) because you used concrete class, not interface Based on my practice - we need to create interfaces in situations when we are planning to create several implementations. Most of my interfaces have only one implementation, so i decided not to create interfaces, and bind components in IOC container using inplementation name instead of interface name.
@yhaelopez
@yhaelopez 2 года назад
8:00 PhpStorm: Excuse me?
@MichaMarcak
@MichaMarcak 2 года назад
Na twojej stronie z kursem SOLID piszesz " Want to get a Senior Laravel developer position? You probably need to master software design principles, like SOLID." .. Ale ja śledzę oferty pracy dla juniorów w których już trzeba znać i stosować zasady SOLID :( Źle myślę?
@doktoracula7017
@doktoracula7017 2 года назад
W ofertach dla juniorów podaje się że wymagana znajomość SOLID, ale ostatecznie często nie trzeba ich za dobrze znać. Pamiętaj, że wymagania w ofertach nie muszą być spełnione na 100% żeby zostać zatrudnionym, szczególnie jeśli czymś innym się zaimponuje.
@MichaMarcak
@MichaMarcak 2 года назад
@@doktoracula7017 Na razie nie udało mi się zaimponować rekruterom :( Ale cały czas się edukuje- czeka mnie refaktoring moich projektów na github- może wtedy to pomoże... i kolejna sprawa- chyba najgorsza dla mnie... język angielski - ale uczę się języka - może życia starczy :) hi hi Pozdrówka
@claushellsing
@claushellsing 2 года назад
Hate myself to ask, sorry to be that guy. But any coupon for early buyers ?
@LaravelDaily
@LaravelDaily 2 года назад
Not for early buyers this time. But generally, you can get some discount on all my products, here: coupons.laraveldaily.com
@bumblebity2902
@bumblebity2902 2 года назад
Sadly, SOLID principles you should know applying for first job, unless you are pre-junior/intern. No matter what stack, it is mandatory to know.
@educationey9572
@educationey9572 2 года назад
honestly, for people like who live in worst country in the world(iran) course's price is to high... it's basically salary of 1 months of work... :( I would like to take this course but it's to high to pay for 1-2~ hrs course.
@LaravelDaily
@LaravelDaily 2 года назад
I can't give it away for free, but I can give some discount based on where you live: coupons.laraveldaily.com And this course could easily be longer, 5-6 hours, but I intentionally stripped it down to what you ACTUALLY need to know, without unnecessary stuff.
Далее
How principled coders outperform the competition
11:11
Cat Corn?! 🙀 #cat #cute #catlover
00:54
Просмотров 11 млн
ЛУЧШИЙ ПОДАРОК  @mozabrick #shorts
00:40
Просмотров 1,1 млн
SOLID Principles: Do You Really Understand Them?
7:04
Просмотров 140 тыс.
Laravel Code Review: Why NOT Use Repository Pattern?
14:21
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 252 тыс.
Learn SOLID Principles with CLEAN CODE Examples
28:35
Просмотров 263 тыс.
Laravel vs React
9:40
Просмотров 47 тыс.