So from now on till the end of the lesson, I try to summarize what I've learned: - We can access public & protected properties, constants, and methods of the superclass in subclass - To override public & protected properties and constants of the superclass, we've to use the same or higher visibility - Constructor methods are optional, they are called in the background(In JavaScript as well) - To override the constructor method of the superclass, we have to call "parent::__construct()" with all necessary arguments required in the superclass' constructor method. - To override public & protected methods of the superclass, method signature which is argument type, argument amount, and return type must be the same (this does not apply to constructor method). - To create a constructor method in a subclass, we don't have to also create a constructor method in superclass - We can use inheritance when class has is-a relationship - When class has has-a, can-do relationship then we should use composition
@ProgramWithGio3 жыл бұрын
Great summary 👏. One correction, to override parent's constructor you don't need to call parent::_construct, you need to call parent construct if you want to run parents constructor when you override the constructor method. Good job 👍
@johongirrahimov23433 жыл бұрын
@@ProgramWithGio Yeah got it dude, thanx for correcting me
@ahmedats3353 жыл бұрын
Dude, this is an amazing summary, thank you so much, keep it up. :D I'd like to add this - The constructor of the child class doesn’t automatically call the constructor of its parent class.
@federicobau86513 жыл бұрын
Best PHP and complete course. Better than many paid bootcamps and best quality
@ProgressiveDeveloper9 ай бұрын
This tutorial is more than just advanced and comprehensive. I am using it even in my Python journey. Thanks, GIO❤
@ProgramWithGio9 ай бұрын
That's awesome, glad to hear 💙
@Zubbee2 жыл бұрын
Great lesson. The number of lessons I know I have to revisit are increasing. I'm grateful to be learning php like this with this kinds of resources available. Thanks Gio
@ProgramWithGio2 жыл бұрын
That is perfectly normal, glad you like the videos, thank you
@jemaleakil76202 жыл бұрын
I wish I could subscribe ten times to this channel... Thank you so much for providing this amazing tutorial
@ProgramWithGio2 жыл бұрын
You're welcome, glad you like it 🙌
@tolebiGamingTime3 ай бұрын
Cool course, I'm waiting for the video lesson on microservices)
@ProgramWithGio3 ай бұрын
Thanks
@godmansarah2 жыл бұрын
Love the Toaster, Toaster Pro, and Toaster Pro Pro illustration. So simple and clear :)
@ProgramWithGio2 жыл бұрын
Thank you 🙌
@opheroooo2 жыл бұрын
100%
@dev_troy890311 ай бұрын
I have studied OOP using java in the past, and all I can say, hats off to you Gio. 👏
@ProgramWithGio10 ай бұрын
Thank you. Java is great
@sfa3272 жыл бұрын
This is the best course in php
@ProgramWithGio2 жыл бұрын
Thank you 💙
@michaelerwin8744 Жыл бұрын
I think 21:21 is a good example of inheritance related issue and explains well the application of Liskov Substitution Principle.
@ProgramWithGio Жыл бұрын
Yup, we cover composition as well in the series
@invgreat56082 жыл бұрын
Superb job explaining! Thank you!!
@ProgramWithGio2 жыл бұрын
Thank you 💙
@chenting712 жыл бұрын
25minutes video, I did it for one hour and a half (didn't get the composition yet). Great tutorial !
@ProgramWithGio2 жыл бұрын
Nice work, thank you. We cover composition in 3rd section so you'll get there in time.
@Vitalii-m6r Жыл бұрын
There are a dime a dozen channels for learning PHP, but this one is the best! Thank you!
@ProgramWithGio Жыл бұрын
Thank you 💙
@imanol44687 ай бұрын
👏👏👏 Thank you, Gio. You're the best teacher!!!
@ProgramWithGio5 ай бұрын
Thank you 💙
@donmikele07 Жыл бұрын
Thanks!
@ProgramWithGio Жыл бұрын
Thank you for your support 💙
@ilya_123__ Жыл бұрын
Step by step i trying to finish this course :)
@ProgramWithGio Жыл бұрын
Awesome, keep going
@aleksandrkanygin26723 жыл бұрын
Great tutorial as always
@ProgramWithGio3 жыл бұрын
Thank you 🙌
@PaulNike3 жыл бұрын
Thanks! Very helpful video
@ProgramWithGio3 жыл бұрын
You're welcome, happy to hear that
@karam01012 жыл бұрын
Amazing as usual, thank you very much
@ProgramWithGio2 жыл бұрын
Thank you too 💙
@jeevachaithanyansivanandan3 жыл бұрын
very well explained. thank you
@ProgramWithGio3 жыл бұрын
You're welcome & thank you 🙌
@lotuslando199411 ай бұрын
I just wanted to add my thanks to the long list of thank yous. 🙏 I completed your functional PHP course (Lesson 1) about a year ago, and then immediately tried to start Lesson 2. Because I knew nothing about Docker, I had to take quite a bit of time off to play around with that first. Conceptually, I understand Docker, but still struggle setting up a dev environment with it. Thankfully, you have provided the necessary instructions. I realize you are not teaching a Docker course here! It's just what makes most sense to use in this context. As I'm basically a noob when it comes to programming, I found Lesson 1 to be quite challenging. But I was able to complete the final project, albeit it was not as elegant a solution as yours. Lesson 2 feels like it's so many more levels above Lesson 1, and not really a continuation. I feel that if I knew at least one other programing language, especially an object oriented one, I would be following along with ease. Instead, I'm finding it all quite challenging conceptually. I'm re-watching the videos multiple times. I type out all the code you're showing and test everything. I really am struggling to retain and understand how all these parts fit together. I'm nowhere near the project part yet, but I really do wonder if I'll be able to actually do it. There seems to be so many other things, outside of PHP, that I need to understand first. I'm going to keep persisting in the hopes that maybe it will all start to make sense at some point. This is not a critique of your teaching style whatsoever, which is very, very good. It's more a statement about me having a lack of programming fundamentals to be able to shift to this object oriented world. With regards to the current video, I really liked that you used Toasters as an example to explain inheritance. This non-abstract approach made the inheritance concept much easier to understand! 👍 🍞
@ProgramWithGio10 ай бұрын
First of all, great job on completing the first section. Second & third sections are harder for sure. The docker video & the docker in general is not a requirement. You can keep using XAMPP and follow along with it, I just used Docker as an alternative so that way I could cover nginx/fpm as well since in first section we did apache. If you feel like you may have a gap somewhere in between videos, stop the videos, do research (e.g. read docs, articles, try it out) & practice. You won't retain knowledge by watching tutorials if I'm being honest, most knowledge is retained after trying to work with it, break it, fix it, practice, etc. Feel free to ask any questions along the way, happy to help & clarify where needed. You can reach me at Twitter (X)
@superheroshortss Жыл бұрын
Great Explanation. Love it Gio
@ProgramWithGio Жыл бұрын
Thank you
@parinataneja70992 жыл бұрын
Hi again, thanks Gio :) I am learning so much new stuff from this tutorial. Keep Rocking!
@ProgramWithGio2 жыл бұрын
Happy to hear that, thank you
@janwan3 жыл бұрын
I really like your tutorials. It's really a refresher for me.
@ProgramWithGio3 жыл бұрын
Glad to hear that 🙌
@ferdinandeke95903 жыл бұрын
Hey man, thanks a bunch for your insightful tutorials..the contents here are really helpful.. I'm an advance php-laravel developer though from a Java background, but honestly I felt the need to learn php from scratch again cos I love the approach you adopted, really in-depth, and I'll be on ur channel a lot to see contents in the future.. cos I look forward to learning Laravel indepth the way you treated php, cos I just know how to implement my tasks and get my applications running on Laravel but I felt the burden to really understand the concepts in detail, cos it's quite a lot on Laravel and I just know how to do stuffs but don't have a sound understanding of a lot of terminologies, for instance I took a dev stack test, php-laravel, I passed the php and then failed Laravel which I was a lot easier but certain terminologies just confused me and funny enough I knew the answers but couldn't relate them to the best fit for the questions... So I hope to see a lot more of you contents.. Many thanks to you..
@ProgramWithGio3 жыл бұрын
Thank you so much. There will be a lot more content including Laravel once I'm done with this course. I put a lot of effort in each video regardless of how easy the topic is. I try to teach it the way I would want to learn it myself. A lot of times small details are left out from tutorials that leave me confused, so that is the gap in trying to fill. That is why sometimes it takes me awhile to publish a video.
@ferdinandeke95903 жыл бұрын
@@ProgramWithGio I also started off teaching my colleagues programming at the office, trying to build a team of my own, so I'll be referring each and everyone of them to you channel to join in and be part of this channel.. warm regards!
@ProgramWithGio3 жыл бұрын
@@ferdinandeke9590 thanks alot. I appreciate it 🙏
@elizabethsullivan1894 Жыл бұрын
This is incredibly useful! I've been doing some Python just to automate some tedious tasks, but I wanted to learn PHP to make a web-based tool. Even though the syntax is different, it's interesting how much of this course also translates over to Python and to the VBA I use sometimes in my job.
@ProgramWithGio Жыл бұрын
That's awesome, happy to hear 🙌
@omaryahia Жыл бұрын
your explanations are sooo amazing , love your videos man, thank you soo much❤🌟
@ProgramWithGio Жыл бұрын
Glad you like them, thank you
@keremardicli4013 Жыл бұрын
Simply perfect 😮
@ProgramWithGio Жыл бұрын
Thank you
@muditgulgulia53502 жыл бұрын
Found this course while revision all my logic, and thinking why it was not available 3 years back. Great Content!
@ProgramWithGio2 жыл бұрын
Thank you 💙
@JustMeItsMMN9 ай бұрын
Thank you so much bro
@ProgramWithGio8 ай бұрын
Yup, I'm working on Laravel course
@techatival3 жыл бұрын
Again a great video.
@ProgramWithGio3 жыл бұрын
Thank you 🙌
@memack1012 жыл бұрын
Thank you.
@ProgramWithGio2 жыл бұрын
👍
@simplecad7462 Жыл бұрын
Great tutorial! Using terminal instead of localhost page makes debugging much faster and takes less space from screen. I found out for vscode + docker i have to type "docker exec (container id) php src/public/index.php" to run index.php file inside terminal.
@ProgramWithGio Жыл бұрын
Thank you
@udayan285 Жыл бұрын
Thank you Gio.
@ProgramWithGio Жыл бұрын
You're welcome
@chadcglk79512 жыл бұрын
It would be great to see vanilla php app tutorial, see all these concepts in action.
@ProgramWithGio2 жыл бұрын
We'll work on an app at the end, though I'm still working on figuring out the details but it won't be fully vanilla since we'll be using some packages.
@rustem6388 Жыл бұрын
Thank you!!!🙂
@ProgramWithGio Жыл бұрын
No problem 😊
@emekatimothyiloba699 Жыл бұрын
Thank you Gio
@ProgramWithGio Жыл бұрын
You're welcome
@mahdou36082 жыл бұрын
greate course thanks a lot
@ProgramWithGio2 жыл бұрын
Glad you like it, thank you
@ДухДмитро3 жыл бұрын
great work
@ProgramWithGio3 жыл бұрын
Thanks
@bulent24352 жыл бұрын
great work, thanks.
@ProgramWithGio2 жыл бұрын
Thank you
@badevent Жыл бұрын
Awesome! I love, mate!
@ProgramWithGio Жыл бұрын
Glad you like it 🙌
@santvar3802 жыл бұрын
Excellent job, could you be so kind and share the composition video link?
@ProgramWithGio2 жыл бұрын
Thank you. There is a link to the course outline in description, you can find all lessons here: github.com/ggelashvili/learnphptherightway-outline
@mimoh20002 жыл бұрын
Hi, just a quick one . Trying out the Debt collector and CollectionAgency example. Both are in the same App namespace. Running individual scripts are ok. But when I try to implement the DebtCollector,. Am getting "Interface App\CollectionAgency not found in src/app/DebtCollector. But thinking DebtCollector should be the interface. Does interface require any modifications to the autoload to work.
@ProgramWithGio2 жыл бұрын
Hello. It shouldn't, send me screenshots of your code on Twitter and I'll help troubleshoot it
@mimoh20002 жыл бұрын
@@ProgramWithGio Thanks. Just found out that PHP cli doesn't resolve autoloads with interfaces. Runing "php CollectionAgency.php" throws an error. But running "php DebtCollector.php" works find. I did implement the collection() function " class CollectionAgency implements DebtCollector { public function collect(float $ownedAmount): float{ return 2.0; } } Then on the index.php, I created an instance of the CollectionAgency, viola everything works. $clAg = new CollectionAgency(); var_dump($clAg); Result: object(App\CollectionAgency)#3 (0) { } Please another question is why the #3 ?. Thanks
@ProgramWithGio2 жыл бұрын
@@mimoh2000 ah I see, yes because autoloading is not enabled in those files. Autoloading is added in index.php as in the video & in CLI you should just run php index.php. #3 is the object identifier.
@bhaidar3 жыл бұрын
Hi Gio, I noticed we access the parent methods using :: as if the parent methods are static. Why is that? Thanks
@ProgramWithGio3 жыл бұрын
Hey Bilal. Scope resolution operator '::' is not only for statics. From the PHP docs: "The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class." www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php Here is an example to illustrate why: Class A { public function foo() {...} } Class B { public function foo() { // this will cause recursion & will keep on calling method foo on class B. What developer meant was to execute method foo on parent class so you use parent::foo() $this->foo(); } }
@bhaidar3 жыл бұрын
@@ProgramWithGio Thanks Gio. As usual very useful video
@Meow_Beyond3 жыл бұрын
again it's real helpfull
@ProgramWithGio3 жыл бұрын
Glad to hear that 👍
@johongirrahimov23433 жыл бұрын
I've written everything the same including the folder structure but PHP throwing following error: Fatal error: Uncaught Error: Class "App\Toaster" not found in /var/www/App/ToasterPro.php:9 Stack trace: #0 /var/www/public/index.php(8): require_once() #1 {main} thrown in /var/www/App/ToasterPro.php on line 9
@ProgramWithGio3 жыл бұрын
Most likely it's the issue with autoloading. Share your composer.json contents & public/index.php. Also run composer dump-autoload or composer install
@johongirrahimov23433 жыл бұрын
@@ProgramWithGio I tried to run composer dump-autoload and composer install but it's still throwing the same error as in my comment. It'd be amazing if you could help me fix issue file { "require": { "ramsey/uuid": "^4.2" } } file
@johongirrahimov23433 жыл бұрын
@@ProgramWithGio And additionally in file. this function is underlined with red line indicating it has issue and when I hover over this function it's saying, Undefined function. It is in line 31 in my Code Editor. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
@ProgramWithGio3 жыл бұрын
You are missing the autoload option in the composer.json. I put the exercise & project source in github, you can take a look at the composer.json file there. For future I'll make sure to also include code for this kind of lessons as well when its not a project or exercise. Should be something like this: { "require": { "ramsey/uuid": "^4.2" }, "autoload": { "psr-4": { "App\\": "app/" } } } assuming that you are following the same folder/namespace structure. Add that in & run composer dump-autoload again
@johongirrahimov23433 жыл бұрын
@@ProgramWithGio Oh man, I can not thank you enough. You don't know how happy I feel now, I spent hours to fix this issue. Pro is pro. you are my PHP hero. thank you a lot again and god bless you to have 1+million subscribers sooner
@ינוןאלבז-כ1ז2 жыл бұрын
High level!!!
@ProgramWithGio2 жыл бұрын
Thanks 🙏
@AMoktar Жыл бұрын
Thanks ❤
@ProgramWithGio Жыл бұрын
You're welcome
@z3ko3 жыл бұрын
Hello again :) great work. In the last part (FancyOven implementation) when you pass Toaster object thru constructor is that considered Dependency Injection?
@ProgramWithGio3 жыл бұрын
Hello & thank you 🙌. Yes that's dependency injection. There will be a lesson about dependency injection in 3rd section where I'll go in more detail.
@z3ko3 жыл бұрын
@@ProgramWithGio Nice, thank you
@Meow_Beyond3 жыл бұрын
great video all wishes to you brother:(
@ProgramWithGio3 жыл бұрын
Thank you 🙌
@WhiteSiroi2 жыл бұрын
love it
@ProgramWithGio2 жыл бұрын
💙💙
@Armando-px8hi Жыл бұрын
The best, I am not gonna talk long! Just one question Gio please, as you said one of the bad things of inheritance is that the child class will inherit all the properties and methods that are public or protected, so if we do not need them to be inherited can not we just define the final keyword or it still will be inherited just we would not have an access to them?
@ProgramWithGio Жыл бұрын
Final prevents method overriding, but your child class can still call the parent method, so that's what I mean by inheriting properties & methods
@Armando-px8hi Жыл бұрын
@@ProgramWithGio Got it, thanks 🙏
@journeytocoding8162 жыл бұрын
Hello Gio, Thanks for another great tutorial. My question is if I want to make multi login in a website with logins (admin, Seller, Customer) .should I make base class as user, then class admin ,then class Seller, Then class Customer?? I haven't made anything yet just asking as curiosity.
@ProgramWithGio2 жыл бұрын
That's one way but a better way would be to have User class and use permissions/roles to control what kind of access user has.
@journeytocoding8162 жыл бұрын
@@ProgramWithGio thankyou Gio.
@chenting712 жыл бұрын
Finally got the composite works: class Gun { public $a = 1; public function foo(){ echo 'shoting bullets ---------->>>>>>'; } } // build a tank with method foo() belongs to Gun (shooting out something) class Tank { public Gun $shot; // or you can omit, or make it private(see bellow) public function __construct(Gun $shot) // take in another class as parameter { $this->shot = $shot; // initialise $shot and give it property name shot } public function shotGun(){ // give a public function to all shot->foo(), $this->shot->foo(); // in case you made shot property private(see remark line 1) } } $b = new Tank(new Gun); // give Gun $object as parameter - composite😁 another class $b->shotGun(); // use local method (inside it calls method of class belongs to other) $b->shot->foo();
@ProgramWithGio2 жыл бұрын
Awesome 👍
@lynic-0091 Жыл бұрын
I have one question, why didn't you move the toast and toastBagel methods to a Traits / Concerns folder, and named the trait something like CanToast.php ? Then those methods also could've been reused in the FancyOven class, without inheritance, by using that CanToast trait.
@ProgramWithGio Жыл бұрын
We could but this was lesson about inheritance. Also note that traits should not be used to define a contract, ideally it would be a combination of interfaces + traits or simple composition (which we cover later in the series & is also shown at the end of this video), but this lesson was just about inheritance.
@Em1lka_ Жыл бұрын
Hello Gio! I would like to know if there is any point in solving problems using codewars? They are just difficult and I am not sure that I will get important knowledge from there. I would like to hear your expert opinion!
@ProgramWithGio Жыл бұрын
It's good to practice some skills but I don't think it's something you would use on your day to day job. It's good to pass some time & practice some skills depending on what type of challenges they have but I would spend more time building real things, that will give you the most practice & practical experience
@Em1lka_ Жыл бұрын
@@ProgramWithGio Thank you 🙏
@saldinhozey4967 Жыл бұрын
Hi Gio, Nice tutorial, I am trying out this illustration but nothing is being printed out as output. Please help.
@ProgramWithGio Жыл бұрын
Hey, thank you. Can you share your code? You can DM me on Twitter & send me screenshots or link to GitHub repo and I can take a look.
@mahmoudadel83132 жыл бұрын
why u didn't talk about traits bec it's related to inheritance topic
@ProgramWithGio2 жыл бұрын
Traits has a dedicated lesson & it's not directly related to inheritance
@mahmoudadel83132 жыл бұрын
@@ProgramWithGio when I Google it about traits I found it's present in php to make php support multi inheritance is it ?
@ProgramWithGio2 жыл бұрын
@@mahmoudadel8313 in a way yes, since PHP has no native multi inheritance support, traits can be used to kind of achieve that but it's not really multiple inheritance. Check the playlist there is a lesson about Traits.
@mahmoudadel83132 жыл бұрын
@@ProgramWithGio ok I will continue this great playlist by the way u are amazing thank u
@ProgramWithGio2 жыл бұрын
@@mahmoudadel8313 👍. Thank you 🙌
@deepakpatil4196 Жыл бұрын
oh my toaster🤕
@ProgramWithGio Жыл бұрын
😁
@MahmoudAhmed-pc2xw11 ай бұрын
Best PHP and complete course. Better than many paid bootcamps and best quality