A real road map to learn PHP. Sometimes, I have to spend good time offline to grasp and have chewed understanding of your tutorial. Which is expected. Greatgreat guidance!
Super professional video tuts... so many details...even mid devs find a lot of interesting things. What a job has been done! Thank you! Definetly donate, if i find a job)
7 pages of notes on this video (with code examples) :D You are on another level with you knowledge and ability to clarify compared to all of the other sources.
Man you keep on rockin! Starting at 00:00 I must admit that I thought that this video is going to be of no interest to me. I was wrong. __invoke & __toString are most interesting to me. Where __call & __callStatic are not short after. Wonderful, thank you Gio 🏆
Watched thrice already. Each time things were clearer but I still didn't get some magic methods (__call and __callStatic). But you did say not to worry if we don't get it as of now. Thanks alot Gio
Thanks for your great tutorial. I request to you that can you please make your playback little slow.? sometimes I really get over whelmed by your speaking speed.
Thanks for the feedback. I know about that and improved on it in later videos. You can also adjust the speed on UA-cam and slow it down for those that are too fast
Thanks for the great video! I think using the magic methods should be done when someone builds a framework or something like that. I see no reason to use the_get or _set_ for example on a project that has business logic, imagine unsetting or setting properties on the fly...
You could, it's just if you have a class with just a single method you might like the invokable option better, it comes down to preference, nothing wrong with having a single method in a class
Thanks for the great series! Do I get it right that the __invoke pattern can be used to make a function available to a class via DI so it is a explicit dependency instead of relying on a regular function to be present?
$this->property accesses the value of the property defined in the class, $this->$property access the value of a property whose name comes from the value of variable $property. Its variable variables, we covered that in first section.
Sir really i have watching this video 10 time ...i cant remember this lots of information...how can we practice to get a better more understanding practicaly
The best thing to do is try it out on a project. Build a todo list or even refactor the exercise from the first section and try to apply magic methods to it.
It's ideal if you don't execute any methods in constructor because then when you inject that class as a dependency anywhere else if you use autowiring DI it will be executing it every time and can affect performance depending on what the method is or worse perform some updates again depending on what that method does.
Is there any reason why one would do a single responsibility class with the __invoke magic method, when one could just maybe write a simple function? 🤔
Mostly it's preference. Usually used got single action controllers or when you have action classes with single methods. You can also pass an object of class as callable/closure when it is invokable, though I haven't tried this in awhile so you would have to test it
It's called variable variables. We covered that in the first section. $this->name would return the value of name property where $this->$name returns the value of the property of whatever the $name evaluates to.
Hey, I wonder if you could make a video of how to use PHP with javascript. I know how to use JS but when it comes to PHP and JS working together with HTML, I have no clue how to connect them when it comes to DOM to add some JS
public function __call(string $name, array $arguments) { if (method_exists($this, $name)){ $this->$name(...$arguments); # instead of call_user_func_array([$this, $name], $arguments); } } Hi sir, I found out this, it also worked. Are they different ?
That would work as well, in this example they are pretty much the same, might be some differences in terms of performance but I have not benchmarked it.
Hey, Gio, thanks for your hard work, I love course very much so far! Just wanted to add that code on ua-cam.com/video/nCxnzj83poQ/v-deo.html will cause the error if you comment out the line $invoice->amount = 35; The Error is "Typed property app\Invoice::$data must not be accessed before initialization". I guess the solution is just setting to $data property default value []
A real road map to learn PHP. Sometimes, I have to spend good time offline to grasp and have chewed understanding of your tutorial. Which is expected. Greatgreat guidance!
Glad to hear, thank you 💙
Best php magic method tutorial and best php course, better than paid bootcamps
This channel is the channel with the most value on UA-cam, and on the web in general, by far
Thank you 💙
Super professional video tuts... so many details...even mid devs find a lot of interesting things. What a job has been done! Thank you! Definetly donate, if i find a job)
Thank you, glad you find videos useful 🙌
This is how to make php great again, very good content
Thank you 💙
Exact!
7 pages of notes on this video (with code examples) :D You are on another level with you knowledge and ability to clarify compared to all of the other sources.
That's awesome :). Thank you so much 🙏
Sir also include exception handling in this oop tutorial. Your tutorials make doubts crystal clear
Definitely, exceptions lesson coming up soon
man your vidoes make everything clear thank you so much for this great content.
Glad to hear that, you're welcome & thank you 🙏
Gamarjoba, Gio! Great tutorial! Thank you for your hard work! TM from PL :-)
Gamarjoba 👋. Thank you 🙏
Man you keep on rockin! Starting at 00:00 I must admit that I thought that this video is going to be of no interest to me.
I was wrong.
__invoke & __toString are most interesting to me. Where __call & __callStatic are not short after.
Wonderful, thank you Gio 🏆
Happy to hear, thank you
Thank you for this awesome tutorial
You're welcome. Thank you!
There are plenty of magic methods. Thanks for this tutorial!
You're very welcome
Watched thrice already. Each time things were clearer but I still didn't get some magic methods (__call and __callStatic). But you did say not to worry if we don't get it as of now. Thanks alot Gio
You'll see more examples of call & call static in third section and will understand it more 👍
Another great tutorial. Thank you for sharing all these concepts
Thank you 🙌
Magic methods are very interesting lesson. thank you
Glad you like them. Thank you
Thanks a Ton!
You're welcome
The best of the best!)
Thank you
thank you!
You're welcome!
Thank you.
You're welcome!
Thank you SO MUCH!!!
You're welcome!
you are amazing dude
thank you
No, you're amazing, thank you 🙌
Great!! I request you to please create the course for laravel and explain whatever OOPS concept is used there.
Thank you. I'll have more laravel content once I finish this series
@@ProgramWithGio Thanks. I will be waiting for new awesome laravel series.
Thanks for your great tutorial. I request to you that can you please make your playback little slow.? sometimes I really get over whelmed by your speaking speed.
Thanks for the feedback. I know about that and improved on it in later videos. You can also adjust the speed on UA-cam and slow it down for those that are too fast
Thanx 🎉
No problem
Thanks for the great video!
I think using the magic methods should be done when someone builds a framework or something like that. I see no reason to use the_get or _set_ for example on a project that has business logic, imagine unsetting or setting properties on the fly...
It depends, it can be useful in non framework/library code as well. Although, I agree with having less magic in userland
@@ProgramWithGio Thanks for the reply and your videos! Great job!
thank you @Gio,
in 14:51 you said you needed class with one method than why didn't you just declare a function instead ?
You could, it's just if you have a class with just a single method you might like the invokable option better, it comes down to preference, nothing wrong with having a single method in a class
Magic methods are indeed magic. It is hard to wrap my head around.
Heh, yea it can be tricky at times
Amazing series thank you. After years with php still something to learn. Can you deep dive to laravel to show those magic methods in action?
Thank you 🙌. I'll be doing more Laravel content in 2023
@@ProgramWithGio Glad to here that. Wish you best of luck
@@kvanca2330 thank you 🙌
Thanks for the great series! Do I get it right that the __invoke pattern can be used to make a function available to a class via DI so it is a explicit dependency instead of relying on a regular function to be present?
Invoke just makes class be called as a function. Makes something like this possible: (new A())()
Hey Gio ,what's the difference between accessing properties as $this->$property and as $this->property , cuz both ways work!
$this->property accesses the value of the property defined in the class, $this->$property access the value of a property whose name comes from the value of variable $property. Its variable variables, we covered that in first section.
Sir really i have watching this video 10 time ...i cant remember this lots of information...how can we practice to get a better more understanding practicaly
The best thing to do is try it out on a project. Build a todo list or even refactor the exercise from the first section and try to apply magic methods to it.
Hi Gio, could you recommend any plugins for php storm? Something for php/laravel
I don't really use any plugins, only when I have specific needs but for the most part phpstorm is enough
i hop you start laravel course before i finish this course
I hope too :)
By the way, I understand those magic methods as "Event Trigger" provided by PHP, when operating on $object :D
👍
Hi Gio, thank you for this , What is the advantage of using __invoke vs calling a function from the constructor ?
It's ideal if you don't execute any methods in constructor because then when you inject that class as a dependency anywhere else if you use autowiring DI it will be executing it every time and can affect performance depending on what the method is or worse perform some updates again depending on what that method does.
Is there any reason why one would do a single responsibility class with the __invoke magic method, when one could just maybe write a simple function? 🤔
Mostly it's preference. Usually used got single action controllers or when you have action classes with single methods. You can also pass an object of class as callable/closure when it is invokable, though I haven't tried this in awhile so you would have to test it
Sorry, Gio, why do we have "return $this->$name"? I thought it should be the conventional "$this->name". Or have I missed something?
It's called variable variables. We covered that in the first section. $this->name would return the value of name property where $this->$name returns the value of the property of whatever the $name evaluates to.
@@ProgramWithGio
Ah! Thanks. I didn't read it that way.
Hey, I wonder if you could make a video of how to use PHP with javascript. I know how to use JS but when it comes to PHP and JS working together with HTML, I have no clue how to connect them when it comes to DOM to add some JS
The project that we'll work on at the end of the series will have some JavaScript so that might be helpful.
👍🙏
🙏
volim
💙💙
There is nothing magical about these methods 👎
That's what it's called 🙂
@@ProgramWithGio I know 🤷🏻♂️
public function __call(string $name, array $arguments)
{
if (method_exists($this, $name)){
$this->$name(...$arguments);
# instead of call_user_func_array([$this, $name], $arguments);
}
}
Hi sir, I found out this, it also worked. Are they different ?
That would work as well, in this example they are pretty much the same, might be some differences in terms of performance but I have not benchmarked it.
Hey, Gio, thanks for your hard work, I love course very much so far!
Just wanted to add that code on ua-cam.com/video/nCxnzj83poQ/v-deo.html will cause the error if you comment out the line $invoice->amount = 35;
The Error is "Typed property app\Invoice::$data must not be accessed before initialization". I guess the solution is just setting to $data property default value []
I just watched video further, so nevermind 😀