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

Sdílet
Vložit
  • čas přidán 24. 07. 2024
  • 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
  • Jak na to + styl

Komentáře • 96

  • @giacomogaravaglia6742
    @giacomogaravaglia6742 Před 2 lety +89

    "I'm not in the mood to fix it." Everyone in their programming life has said it at least once!

    • @LaravelDaily
      @LaravelDaily  Před 2 lety +15

      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 Před 2 lety +5

      @@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  Před 2 lety +3

      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 Před 2 lety +5

      @@LaravelDaily Make a t-shirt with the phrase

  • @lynic-0091
    @lynic-0091 Před 2 lety +29

    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 Před 2 lety +2

    The presentation of information is so simple and extensive that you are surprised at the skill of the narrator. True artisan)

  • @yhaelopez
    @yhaelopez Před 2 lety +6

    I loved the way you explained SOLID. Finally, I can say that I'm starting to understand it.

  • @assanesambagueye4132
    @assanesambagueye4132 Před 2 lety +13

    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

  • @nirajgautam403
    @nirajgautam403 Před 2 lety +2

    You are my inspiration of upgrading my coding standards daily. Thank you

  • @christiansenmarcus
    @christiansenmarcus Před 11 měsíci +2

    Best description of SOLID in Laravel I've seen. Thank you.

  • @demiurgich
    @demiurgich Před 2 lety +1

    Thank you, Povilas! You are perfect simplifier! Even I could not explain those principles in more understandable way.

  • @JigarDhulla
    @JigarDhulla Před 2 lety +1

    Thank you. Agree it is not easy to find SOLID examples in PHP with real life examples. Thanks for this and the course.

  • @marcoantonio7634
    @marcoantonio7634 Před 6 měsíci

    I love how you explain the code, it really expands my knowledge

  • @L-A-O-S
    @L-A-O-S Před 2 lety

    I always wanted to learn more about SOLID. Thanks!

  • @codewithfongoh
    @codewithfongoh Před rokem +2

    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

  • @TheHBR99
    @TheHBR99 Před 2 lety

    Finally you made it easily understandable to me. Thanks a lot!

  • @phanta5m
    @phanta5m Před 2 lety +1

    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

  • @TahsinAbrar
    @TahsinAbrar Před 2 lety +3

    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 Před 2 lety

      You might even say "Sometimes reality gets in the way of our idealism"

  • @i_m_denny_
    @i_m_denny_ Před rokem +1

    Hey Povilas,
    Brilliant Content!
    Thank you for sharing your knowledge.

  • @bmtamim7818
    @bmtamim7818 Před 2 lety +1

    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😍

  • @okz9908
    @okz9908 Před 2 lety +1

    you really just doing a great explanations in your CZcams channel

  • @unitaxi1644
    @unitaxi1644 Před 2 lety +1

    Very usefully and easy to understand! Thank you!
    Please make a video about Laravel websockets (Pusher). It will be great job!

    • @LaravelDaily
      @LaravelDaily  Před 2 lety +5

      I will create a full course about it, later in 2021.

  • @ironspider9026
    @ironspider9026 Před 2 lety +1

    Very well explained the information here is pure gold. Thanks for sharing wish I could give 1k likes to the video.

  • @user-zh2oz9fe4m
    @user-zh2oz9fe4m Před 11 měsíci

    I'm very grateful for your extremely useful videos!

  • @ghostza1209
    @ghostza1209 Před rokem +2

    Thanks i’ll enroll your corse shortly

  • @RehmanKhan-zv2rl
    @RehmanKhan-zv2rl Před 2 lety +2

    Sir! great effort, its very helpful, thanks.

  • @Diego-eb9we
    @Diego-eb9we Před rokem

    Best teacher ever. Thank you!

  • @GergelyCsermely
    @GergelyCsermely Před 2 lety +1

    Thanks, I'm happy to leran sometning new again :)

  • @salahuddinayubi3906
    @salahuddinayubi3906 Před 2 lety

    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  Před 2 lety

      Sorry, those topics are not in plans, too narrow edge topics for my audience.

  • @eugenelviv7490
    @eugenelviv7490 Před rokem

    This is the best explanation I met

  • @phil86_
    @phil86_ Před 2 lety +1

    Great tutorial as always

  • @belce1982
    @belce1982 Před 2 lety

    Thanks as always!

  • @zieddams
    @zieddams Před 2 lety +1

    thank you for this content

  • @zoeebabaee
    @zoeebabaee Před 10 měsíci

    Thank you so much 🙏🙏

  • @user-xz7vy5bz1x
    @user-xz7vy5bz1x Před 9 měsíci

    Хороший английский, превосходное видео!
    Спаасибо

  • @MahmoudMohsab
    @MahmoudMohsab Před 2 lety +1

    great job as usual

  • @mistersimeeec
    @mistersimeeec Před 2 lety +1

    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  Před 2 lety

      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.

  • @valencefredrick7495
    @valencefredrick7495 Před rokem

    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?

  • @nerjuz
    @nerjuz Před 2 lety

    Readable, maintainable and TESTABLE!

    • @LaravelDaily
      @LaravelDaily  Před 2 lety +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.

  • @bremg9185
    @bremg9185 Před rokem

    Nice! But how many methods/resposabilities does that controller have?

  • @TheMarcelitto
    @TheMarcelitto Před 2 lety

    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  Před 2 lety +1

      You may specify a few types to return: type, null or exception

  • @ZamirMubashir
    @ZamirMubashir Před rokem

    Thanks!!

  • @mohamedruzaik3483
    @mohamedruzaik3483 Před 2 lety +1

    Sublime is perfect for showing code

  •  Před 2 lety

    shouldn't ReportDownloadInterface extends ReportDataInterface intead of implementing both?

  • @kaisertushar7554
    @kaisertushar7554 Před 2 lety

    Thanks for awesome courses. Do you have any plan making a course for Laravel Octane?

    • @LaravelDaily
      @LaravelDaily  Před 2 lety +1

      No, I haven't used it myself, and not planning to.

  • @RizkheyG
    @RizkheyG Před 2 lety

    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?

  • @davenegasn
    @davenegasn Před rokem +1

    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?

  • @PetarVasilevX
    @PetarVasilevX Před 2 lety

    I didn't quite understand the Liskov substitution principle. Like what exactly is the problem there? Any other examples?

  • @bebebeb6498
    @bebebeb6498 Před 2 lety +1

    Thx 👍

  • @salahuddinayubi3906
    @salahuddinayubi3906 Před 2 lety

    you are genius

  • @dfordemo981
    @dfordemo981 Před 2 lety

    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? 😁

  • @alexaverkiyev9099
    @alexaverkiyev9099 Před 2 lety +1

    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  Před 2 lety +5

      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.

  • @abdulrehmandar8541
    @abdulrehmandar8541 Před 2 lety

    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  Před 2 lety

      Read the package documentation for it, I remember they do have Media Collections or something like that.

    • @abdulrehmandar8541
      @abdulrehmandar8541 Před 2 lety

      @@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.

  • @fcolecumberri
    @fcolecumberri Před 2 lety

    Which pages would you recommend to search laravel jobs

  • @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.

  • @phpcoding9282
    @phpcoding9282 Před 2 lety +1

    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  Před 2 lety +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 Před 2 lety +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.

  • @butcherfirewaters
    @butcherfirewaters Před 2 lety +1

    this principle asked me when i apply position - Junior Laravel developer )

    • @LaravelDaily
      @LaravelDaily  Před 2 lety

      And how did it go for you? :)

    • @butcherfirewaters
      @butcherfirewaters Před 2 lety

      ​@@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  Před 2 lety

      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 Před 2 lety

      @@LaravelDaily ))) Thanks for supporting and for your videos. It's really helping a lot of people!

    • @bumblebity2902
      @bumblebity2902 Před 2 lety

      @@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.

  • @goichikawasoe163
    @goichikawasoe163 Před 2 lety

    Excuse me, what would you recomend to use with laravel? Vue.js or react.js?

    • @LaravelDaily
      @LaravelDaily  Před 2 lety

      Vue is much more popular, with more examples.

    • @goichikawasoe163
      @goichikawasoe163 Před 2 lety

      @@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 :)

  • @barktwain
    @barktwain Před rokem

    I liked developing with sublime, but phpstorm is far better! :)

  • @jimishukurow2286
    @jimishukurow2286 Před 2 lety

    Royal like from me. I use VScode.

  • @amra-dev
    @amra-dev Před 2 lety +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?

  • @llBestBoyll
    @llBestBoyll Před 2 lety

    PHP ❤️💪🏼🔥🔥🔥

  • @MichaMarcak
    @MichaMarcak Před 2 lety

    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 Před 2 lety +1

      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 Před 2 lety

      @@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

  • @ramziddinrustamov5221
    @ramziddinrustamov5221 Před 10 měsíci

    😊

  • @romanperegudov2723
    @romanperegudov2723 Před 2 lety

    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 Před 2 lety

    8:00
    PhpStorm: Excuse me?

  • @claushellsing
    @claushellsing Před 2 lety +1

    Hate myself to ask, sorry to be that guy. But any coupon for early buyers ?

    • @LaravelDaily
      @LaravelDaily  Před 2 lety +1

      Not for early buyers this time.
      But generally, you can get some discount on all my products, here: coupons.laraveldaily.com

  • @educationey9572
    @educationey9572 Před 2 lety +1

    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  Před 2 lety

      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.

  • @bumblebity2902
    @bumblebity2902 Před 2 lety

    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.