PHP - Encapsulation & Abstraction - Full PHP 8 Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ม.ค. 2025

ความคิดเห็น • 99

  • @phixphixation7261
    @phixphixation7261 2 ปีที่แล้ว +13

    I am really enjoying all of your lessons, you explain things in depth while keeping it understandable for most people. Even advanced developers can learn something new here. I have been writing PHP applications until 2 years ago when I stopped, I follow your lessons to get back into the game, and it's working! Thanks for all the effort you put into making them.

    • @ProgramWithGio
      @ProgramWithGio  2 ปีที่แล้ว +1

      Thank you so much, that means alot 💙

  • @GYEONGSUGIM
    @GYEONGSUGIM 9 หลายเดือนก่อน +3

    This is one of the best course I've ever seen... Not just how to write php code, but it also explain how to write idiomatic code.

  • @Ab-cj6gl
    @Ab-cj6gl 3 ปีที่แล้ว +10

    Dammann I'm glad I found this channel

  • @channel-gi3nd
    @channel-gi3nd 3 ปีที่แล้ว +8

    The best USEFUL ADVANCED php series on the youtube 👑❤ ... Thanks for that trick

    • @ProgramWithGio
      @ProgramWithGio  3 ปีที่แล้ว

      You're welcome and thank you 🙌

  • @federicobau8651
    @federicobau8651 3 ปีที่แล้ว +13

    Best PHP and complete course. Better than many paid bootcamps and best quality

  • @petruciucur
    @petruciucur 2 ปีที่แล้ว +5

    Only This course gave me confidence that I can reach the advanced php level. Brilliant ! Thanks !

  • @stepanmutsikivsky8987
    @stepanmutsikivsky8987 ปีที่แล้ว +1

    It's not my first time learning OOP concepts, but the first time, when someone clearly say that using simplest getter and setter with private property isn't encapsulation at all! It doesn't change a thing! The property is still absolutely accessible, but with more text to type in and read! I always understand this, but thought that maybe... I don't understand something?..
    Gio the best!

    • @ProgramWithGio
      @ProgramWithGio  ปีที่แล้ว

      Heh, yup. It's usually misunderstood. Thank you 🙏

  • @ינוןאלבז-כ1ז
    @ינוןאלבז-כ1ז 2 ปีที่แล้ว +2

    Again, great lecture

  • @PascalxSome
    @PascalxSome 2 ปีที่แล้ว +3

    Your Tutorial is the best! Easy to learn interactively (don't learn PHP programming without a editor and browser ready). Way better than any page I found.
    I started making my own MVC in PHP with little to no knowledge about OOP. As a sysadmin, Bash and Python are quite familiar in a functional way. Getting my head around OOP was hard at first, but now things are coming together as I learn more essential stuff.

    • @ProgramWithGio
      @ProgramWithGio  2 ปีที่แล้ว +1

      That's awesome, thank you 💙💙

  • @ДалирХужамурадов
    @ДалирХужамурадов ปีที่แล้ว +2

    Just wanted to let you know, that your tutorials are awesome

  • @WhiteSiroi
    @WhiteSiroi 2 ปีที่แล้ว +1

    loving your vids, GOAT ty

  • @ДухДмитро
    @ДухДмитро 3 ปีที่แล้ว +1

    best php tutorial on youtube

  • @ayenewyihune
    @ayenewyihune 2 ปีที่แล้ว

    4:00 this was what I have always wondered about. Thanks for answering.

  • @levani7851
    @levani7851 3 ปีที่แล้ว +11

    that last bonus trick at the end was amazing, my mind is blown... great job, another amazing video!!

  • @smurffronda2951
    @smurffronda2951 2 ปีที่แล้ว +1

    Thank you

  • @kickass1179
    @kickass1179 3 ปีที่แล้ว +2

    great explanation...I'm loving this series...I am making my own document to sum up my PHP knowledge, and this series is HELPING ALOT!! Thanks!!

    • @ProgramWithGio
      @ProgramWithGio  3 ปีที่แล้ว +1

      That's great to hear, thank you 🙏

  • @dipuchundradey
    @dipuchundradey 3 ปีที่แล้ว +1

    Your videos are really beautiful and easy to learn.💗💗💞💞

    • @ProgramWithGio
      @ProgramWithGio  3 ปีที่แล้ว +1

      Thank you so much, glad you like them ❤️❤️

    • @dipuchundradey
      @dipuchundradey 3 ปีที่แล้ว +1

      @@ProgramWithGio Make some videos in Design pattern.

  • @binarybuilder111
    @binarybuilder111 ปีที่แล้ว

    Thank you so much! Your lessons are pure gold!

  • @bracoyote96
    @bracoyote96 ปีที่แล้ว +1

    I already knew about public and private properties and methods but I didn't know about those two ways of accessing private properties. Why do those things exist? Doesn't it defeat the purpose of having private stuff in the first place?
    By the way, I LOVE these videos. Thank you so much for taking the time to make this guide. I feels like something I should have to pay for.

    • @ProgramWithGio
      @ProgramWithGio  ปีที่แล้ว +1

      Thank you, appreciate it. Language supports a lot of things, doesn't mean everything should be used by everyone. Some of those things can be useful for libraries, packages, and some edge case scenarios.

  • @gerardorebolledo3385
    @gerardorebolledo3385 ปีที่แล้ว

    These videos are really enjoyable, good job buddy

    • @ProgramWithGio
      @ProgramWithGio  ปีที่แล้ว

      Glad you like them, thank you 🙌

  • @steelmantv
    @steelmantv 2 ปีที่แล้ว

    Thank you for all this awesome instruction!

  • @kiranugale88
    @kiranugale88 ปีที่แล้ว

    Extemly superb teaching

  • @Vitalii-m6r
    @Vitalii-m6r ปีที่แล้ว

    I used to confuse Abstraction and Encapsulation. Thanks for the explanation!

  • @Zubbee
    @Zubbee 2 ปีที่แล้ว

    Great lesson, I followed. Also heard when you said we may have to listen again, I will do well to do that tomorrow. Thanks Gio.

  • @lairotuT-Tutorial
    @lairotuT-Tutorial 4 หลายเดือนก่อน

    I want to give a double thumbs up!

  • @securecodingdevelopment5023
    @securecodingdevelopment5023 3 ปีที่แล้ว +1

    Excellent ! Thanks!

  • @aleck156
    @aleck156 3 ปีที่แล้ว

    5:45 - that's an idea similar to the concept of immutability of an object, where you're not allowed to modify an already existing object. The only way of making changes is by creating a new instance with new/updated properties.

  • @kunalkharidia1
    @kunalkharidia1 4 หลายเดือนก่อน

    Thanks a lot for such a great tutorial. Watching your videos seems like watching a excellent quality Web Series which keeps the viewer engaged and curious of what the next episode is going to bring up. Guess what!!!!!!. The next episode exceeds the expectations and the bar for viewers expectations rises to next level. It is quite addicting to watch Ur content. It feels like I finish all the episodes at one go. Also I am expecting what the Movie Director has to come up next. Seeing to the in-depth knowledge over the subject and great presentation skills i would suggest if you could bring up a series on "DESIGN PATTERNS - THE GIO's way" would be an ideal candidate for future releases!!!!

    • @ProgramWithGio
      @ProgramWithGio  3 หลายเดือนก่อน

      Thank you for this feedback, happy to hear 💙💙

  • @deniskonvisar6079
    @deniskonvisar6079 ปีที่แล้ว

    fantastic explanation, thank you a lot!

  • @memack101
    @memack101 2 ปีที่แล้ว

    Thank you.

  • @rustem6388
    @rustem6388 2 ปีที่แล้ว

    Thank you!!!

  • @ilya_123__
    @ilya_123__ ปีที่แล้ว

    thank you!

  • @sujanmiya4514
    @sujanmiya4514 2 ปีที่แล้ว

    Nice tutorial

  • @badevent
    @badevent ปีที่แล้ว

    Awesome! I love, mate!

  • @ZeppGoesPro
    @ZeppGoesPro 2 ปีที่แล้ว +1

    Seems like php changes occurred. At 4:25, when i tried to pass setAmount function it results in: Fatal error: Uncaught TypeError: App\PaymentGateway\Paddle\Transaction::setAmount(): Return value must be of type float, none returned.
    Expected type 'float'. Found 'void'.intelephense(1006).
    public function setAmount(float $amount): float
    # setter function for changing the private (encapsulated) property
    {
    return $this->amount = $amount;
    }
    The way it start working for me.

    • @ProgramWithGio
      @ProgramWithGio  2 ปีที่แล้ว +1

      Don't think anything changed related to that. You just need to return the proper type. If you do $this->amount = $amount then you need to return $this->amount.

    • @RedZambala
      @RedZambala ปีที่แล้ว

      I had the same type error, and return $amount; helped; In Gio video there is no Return;

  • @KenGabiola
    @KenGabiola 10 หลายเดือนก่อน

    What compiler do you use? like that, that has live server web extension that easily refresh code changes

    • @ProgramWithGio
      @ProgramWithGio  10 หลายเดือนก่อน

      I don't use any compiler or extensions, its just my IDE phpstorm but I refresh the page manually, I just sometimes cut things out during editing

  • @JohnnyBigodes
    @JohnnyBigodes 3 ปีที่แล้ว +3

    Getters and Setters are not that bad... They are not only made because of encapsulation, but you have better control about what can be written to that private property.
    In your case it shouldnt be a big problem, because your property is properly defined as a float, but with older code wihtout types this could be a problem.
    You could define $transaction->amount = 'Hello There' instead of a float number. With a proper Setter you could easily throw an exception if the value is not an int or float.

    • @ProgramWithGio
      @ProgramWithGio  3 ปีที่แล้ว +1

      Definitely. I mentioned that in the video as well. There are use cases for Getters and Setters outside of simple encapsulation implementation, they are not just for encapsulation. As mentioned in the video sometimes they can break encapsulation instead of fixing it.
      You brought up a good example with the types, that is also correct, if one doesn't use strict types then definitely setter is good to enforce the type and have proper "validation".

    • @JohnnyBigodes
      @JohnnyBigodes 3 ปีที่แล้ว +1

      @@ProgramWithGio Yes, I was also thinking about legacy code, where not every type is available.

  • @ItsDigiUtime
    @ItsDigiUtime ปีที่แล้ว

    I read in a book's intro about design patterns where Abstraction was mentioned in OOP's context and the explanation was that abstraction means that objects only model attributes and behaviors of real objects in a specific context. It kind of does not seem to fit with the way you described abstraction or am I missing/misinterpreting something?
    The example in the book was about a plane, how in the context of a flight simulator, we would care about certain physical aspects that would matter in simulating a flight realistically, but in a booking application we would only care about seats, their availability.
    I am assuming that abstraction is a broader topic and that both you and the author in the book just provided a small fragment of the same topic? In the book it was just a couple paragraphs before moving on to the next topic.
    Book for reference is "Dive Into Design Patterns" by Alexander Shvets

    • @ProgramWithGio
      @ProgramWithGio  ปีที่แล้ว +1

      Yea I think we both are talking about the same thing, though the definition in book may be a bit more fancier. Abstraction is simply where the implementation details are sort of hidden away (abstracted away) from you, so in your example in the context of booking, the user does not care how the booking system is implemented, all the user cares about is to click a button & confirm the flight. To translate that into code, you might have a class called Booking with a method called book. As the user/developer who wants to consume that API & create a booking, all you need to do is instantiate a new Booking class & call the book method, you don't care what happens inside the book method or how its implemented, no other setup is needed by you, all you care about is that booking is created after you call the book method. That's what abstraction is in simpler terms.

    • @ItsDigiUtime
      @ItsDigiUtime ปีที่แล้ว +1

      ​@@ProgramWithGio Appreciate the detailed response, thank you for clarifying that

  • @fraidoonhu9284
    @fraidoonhu9284 ปีที่แล้ว

    Exposing the setter method is not like making the property public, because with setter u have control to check and manipulate the value. u can have criteria to check the value if it meets the criteria or not. In future if u change the rules for the value, u can just change it in one place in setter. Setter method makes it more secure and under control.

    • @ProgramWithGio
      @ProgramWithGio  ปีที่แล้ว

      Sure, but it still gives ability to change the state of your class. It has it's use case though, don't get me wrong.

  • @Operaatoors
    @Operaatoors 2 ปีที่แล้ว

    I am working to get my php code compitable with PHP8.1, and static analyze tools found that I had classes, where some arguments in constructor with default values were before values without default fallback. In tottal it accepts 5-10 values in constructor) Now I found that this class is called in about 10 files. I had to rearrange those arguments, change values in those files. Properties were all public. No setters.
    Does this means that somebody who wrote this class was not following best encapsulation practices, right?
    But basically, it is simple DTO, with two methods to check it state, and another method to get another object based information from this class.
    What would be the better approach? Just use chain setters? Or couple some information pieces together in another smaller DTOs, so it the main DTO would have only 3 arguments in constructor? But I see that it is usually used to fill array value, and it would increase indentation. But now, PHPstorm is even struggling showing all the argument names :D

    • @ProgramWithGio
      @ProgramWithGio  2 ปีที่แล้ว +1

      Having public properties means that it can be written to outside of the class. So inevitably it has conflict with encapsulation. If you don't want those properties to be editable you can use readonly keyword for the properties and keep them public. DTOs should be immutable anyways so readonly properties should work

  • @hakeamgureh2441
    @hakeamgureh2441 3 ปีที่แล้ว

    Is ReflectionProperty php class/php api built in or does it require installation via a composer sort of?. Great tip/trick at the end. Thanks for being awesome

    • @ProgramWithGio
      @ProgramWithGio  3 ปีที่แล้ว

      It's part of PHP. We'll cover Reflection in more detail soon in third section of the series.

    • @hakeamgureh2441
      @hakeamgureh2441 3 ปีที่แล้ว

      @@ProgramWithGio thanks Gio. When is part 3 by the way?

    • @ProgramWithGio
      @ProgramWithGio  3 ปีที่แล้ว +1

      Should be able to start next week I think. Been super busy recently

  • @kingus66
    @kingus66 ปีที่แล้ว

    Thank you so much for this course, the content is great, but those popping-up subscribe banners even for users who already subscribed to your channel are a bit annoying. Please, could you do something about it? Thanks again.

    • @ProgramWithGio
      @ProgramWithGio  ปีที่แล้ว

      They pop up only a couple of times, I don't think is a big deal 🙂. I also put them in places where not much is going on so it doesn't block anything important.

  • @truthteachers
    @truthteachers 2 ปีที่แล้ว

    Hi Bro, your courses are comprehensive unfortunately many of the newbies to PHP in our developer group in the region gave up on your courses. The reason they say is the "rambling on" effect of your presentation. I have mentioned this before. My recommendation is to redo these videos and provide detail explanation. Of course, your effort needs to be rewarded as well. Suggestion is to launch the course in Udemy. Also suggest you timestamp the video as well especially when you cover many topics/concepts in one video. Like this one, i dont know where abstraction starts when i come back later for reference. I hope you do not take these as negative comment but instead use it positively. Tq bro.

    • @ProgramWithGio
      @ProgramWithGio  2 ปีที่แล้ว +7

      Hello. Thank you for the feedback. I agree on couple of parts like having timestamps & on previous videos I speak too fast due to editing errors & the way I speak. That being said though, whoever thinks I am "rambling" can go and watch something else, I've got no problems with that. I am not going to redo these videos into an Udemy course.
      Also I'm not sure what you mean by "provide detail explanation", all of my videos are very detail oriented, it doesn't get any more detailed than that, that's why this series has almost 100 videos in it & is not a "Learn PHP in 3 hours" crash course because it's very detail oriented. You can even see that based on the feedback from the comments on every single video on how detailed it is.
      I'll try adding timestamps on future videos.
      P.S. If they don't understand something or have any specific questions they can always reach out & post comments themselves, I'll be happy to assist & clarify things that may be confusing to them.

    • @truthteachers
      @truthteachers 2 ปีที่แล้ว +1

      @@ProgramWithGio Bro, no one said it is garbage. Perhaps the course is not meant for absolute newbies to PHP. Anyway that is their feedback. Take or drop is your choice. Please dont shoot the pigeon. I am conveying their views and also to avoid 100s of dislikes for all your good effort. Anyway, my apology for upsetting you emotionally.

    • @ProgramWithGio
      @ProgramWithGio  2 ปีที่แล้ว +2

      @@truthteachers I'm not upset and I appreciate the feedback. As I said they can ask me questions directly if something was confusing and I'd be happy to help. I've helped many. I'm not afraid of dislikes either.
      I just care about this stuff because if something is confusing I want to know specifically what and improve on it and also help the person who is confused. Someone just saying "rambling" is not helpful, if they were to say specifically what was confusing or what they didn't understand I would be happy to help.
      Either way, thank you 💙

    • @ProgramWithGio
      @ProgramWithGio  2 ปีที่แล้ว +2

      Nothing against you btw :). I understand you are just conveying their views and I appreciate that. There are many complete beginners who took this course and had no issues, so I think it can work for complete beginners. Some things certainly can be confusing and that's why I offer my help to those who need it.

  • @johongirrahimov2343
    @johongirrahimov2343 3 ปีที่แล้ว

    Clients don't need to know how car operaters, all they have to know is to drive

    • @ProgramWithGio
      @ProgramWithGio  3 ปีที่แล้ว +2

      That is true, but it also depends on what kind of car you give to the client. If you give it a well-designed & functional car, the client will be safer. If you give them a car that malfunctions then it's not so safe. So, in the end, it's correct that the client doesn't care how a car operates but they do care that their car is fully functional & operational

    • @johongirrahimov2343
      @johongirrahimov2343 3 ปีที่แล้ว +1

      @@ProgramWithGio Yeah totally agree. Thank you for reply though

  • @udayan285
    @udayan285 ปีที่แล้ว

    Thank you.