Jeffrey way has a very unique "way" in delivering the most complex information in the simplest & fastest way. I've been following his tutorials since around 2009 when he was still at that Aussie company
Hi Jeffrey, I hope you will see this. First I would like to express my heartfelt gratitude for the priceless contribution you have made to my programming career. I used the PHP for beginners series and I got a distinction in the exams. I once tried Laravel last year on some other channel tutorial but it quickly confused me and I quit. Today, I have completed the Laravel 5.4 series and I am moving to the next Laravel series. Words will never be enough to thank you. You have made more impact than you can even imagine..All the love from Africa, Zimbabwe to be specific.
Hey Jefferey. This is a phenomenal series. I’ve been coding since Jan 2020 and using Laravel since Jan 2021 and have just been rolling with and trusting the frame work. Now thanks to you I’m really starting to get it lol. Awesome man!!!!
Loving the series, I personally want to learn this kind of info than just to "enjoy" using frameworks without any knowledge of whats under the "hood". I think I will build one of my personal websites based on this knowledge. Thank you very much.
I think the require base_path("Core/Validator.php"); was accidentally deleted at 17:45. But I guess the use Core\Validator automatically added by the PHPStorm.
I have learned a lot with how Jeffrey explains complex things. The only part I'm still confused or not fully grasp is how the other files have access to variables or classes through scope. I know you have required files which then whatever is in that file is accessible to the file below it but how I got stack with a routes. Can you explain the flow for me please?
Actually I love building things like routers and database handling myself. I find most frameworks are too huge and cumbersome for the small projects I usually make. And it's a lot more fun to build it yourself, so you know how it works. This series is great in that regard. I couldn't find this series on laracasts. Is it only available her on yt?
So looks like I was on the right path, but derailed along the way. Recently I made an Application class that instantiated a bunch of other classes inside of it - so in my pages I could access things like $App->Database->query() or $App->Router->loadController() .... etc..... I like the idea of having things accessible from a single "resource", and I'm glad that this is actually a "thing"... I just did it wrong. Thanks for the video... I still have to understand namespaces.
Yeah, and one of the nice things about the service container is that you only instantiate what you need when you need it, instead of everything upfront, which saves a bunch of CPU, memory and time.
Hi Jeff one more thing, i have followed others tut about intermediate PHP, in here i want to talk about router specifically. in that tut router just simply to say emulate get request and response to users if available and 404 if not. i was kind lost here about the concept in that tuts just matching request with controller if yes show the page associate with client req and 404 otherwise. one more thing. controller also have some method that match with SUBMIT_QUERY, while the class controller itself match with REQUEST_METHOD
Dear Jeffrey, help me understand the meaning of the App singleton if all its functionality can be left in the container and called static methods from there? Maybe it's just sugar or has a specific practical meaning?
good job , thanks , at the begining of this playlist , all things great , becouse i know every step of what is going on at backend side of the any feramwork .
So if I understood correctly, here our Database class isn't a Singleton because each time we call our resolve class with the corresponding $Key, we keep on recreating the Database object to get access to it? Thanks
at 11:30 you should also let people know that when you have something like a static property it can fill up in memory if you keep on pushing stuff to it, this could cause a memory leak if you use something such as Laravel Octane
Many thanks for this, but I could not understand a point. destroy.php has $db object and it is creating with only App::revolve(Database::class). There is no any __constructors for container and app objects. so how can the app object create the container object ? maybe if I see sources i can make code review. While I watching I could not catch all process. will you put that small project on github?
Cause the App class contains static methods and the $container is a static property. static it means that you can use methods and properties directly without instantiating the class (you don't need a constructor). Usually static classes are often called utility classes referring to the fact that are used everywhere in your code.
At 11:18 Jeffrey starts building App class and he uses "static" property and method. This "static" is what enables you to access them without needing a __constructor. It was covered in previous episodes (cannot remember which one), but try re-watching that part as Jeffrey does explain it again.
You are right. all methods are static. I could not covered calling sequence while watching :). My problem is bindings. There is no binging and I think resolvers are calling bindings.
Bind is just a term, think about it like this, you have a box which contains key : value pairs where each bind is a "key" with a function as a "value". Whenever you want to add a pair to the box, you call the bind method, and whenever you want to use one of the function in the bindings, you call the "resolve" method. Is up to you what the resolve method does.
Hi, Bora. I upload the source code for every lesson to Laracasts. Just find the corresponding episode at phpforbeginners.com, and then scroll below the video for the Source Code link.
DI is a pretty loose term. Typically it means just passing in values to a constructor. So technically in this video Jeffrey was using DI to provide config values to the Database class. Laravel takes DI a step further with autowiring which is made possible because of PHP's reflection API. Basically autowiring works like this. High level methods (controllers, actions, jobs) are invoked by Higher-order Functions (HOF) aka decorators. The HOF inspects the target method's signature using reflection to get a list of wanted parameters. The parameters are resolved using a service container (like what Jeffrey wrote). Then the target method is invoked with a list of resolved variables. But like he said, you wouldn't really want to implement all this yourself. You'd have to add a whole bunch of code to counteract the performance loss from reflection. My guess is you'd probably need some short circuiting and a caching layer. None of that is super important though because you can reuse the HOF that I'm talking about in Laravel. Just use `App::call` to invoke a callable and autowiring will "just work". And, if you're not using Laravel, you can use Symfony's service container, or the PHP-DI library.
I'm not trying to hate, the video overall was very well presented and enjoyable but ... what problem does this exactly solve? To me this seem like a global get_database function with extra steps + a possible missing-bind Exception?
The database resolver is just *one* piece that would go in the container. In real life, countless things would. It's a very common pattern that countless applications use.
@@laracastsofficial I still don't know what problem that solves? Why not just have a services.php file with get_service_a, get_service_b, get_service_c etc ... ?
You can if you want. Either way, you're wrapping the instantiation of an object within a function. How you trigger that function is up to you. But dozens of get_service_a(), get_service_b() functions doesn't sound very nice to me. Also, like I mentioned at the end of the video, keep in mind that an off the shelf container supports so many other things, including singletons, automatic dependency tree resolution, interface binding, etc.
Additionally having a service container will ensure that all your services get to be instantiated once and have a single storage in memory which you can reference with each call to the specifc service. Having dozens of get_service_a(), get_service_b() functions means that you'll be calling the functions and returning new values each time they are defined in code which will eat up more memory. This may become a performance hit if you have a large application. The service container in this tutorial follows the singleton design pattern which is great for performance and code organization.
Blast from the past - I forgot how excellent Jeffrey is at teaching. This guy taught me how to use jQuery back in the day!
Wow, jeff way! Glad to ser you around! I use to learn a lot from you back in jquery days!
Jeffrey way has a very unique "way" in delivering the most complex information in the simplest & fastest way. I've been following his tutorials since around 2009 when he was still at that Aussie company
what you mean in 2009 ? I think he's from the pharaoh times :D
@@awaisweis6605 look how he.looked like 15 years ago.. that was in 2008 or 2009 I think .. th-cam.com/video/yTHTo28hwTQ/w-d-xo.htmlsi=9ruaO-0cxz96-wdn
finally, i understand container after 6 years of working on laravel
Hi Jeffrey, I hope you will see this. First I would like to express my heartfelt gratitude for the priceless contribution you have made to my programming career. I used the PHP for beginners series and I got a distinction in the exams. I once tried Laravel last year on some other channel tutorial but it quickly confused me and I quit. Today, I have completed the Laravel 5.4 series and I am moving to the next Laravel series. Words will never be enough to thank you. You have made more impact than you can even imagine..All the love from Africa, Zimbabwe to be specific.
Thank you!
One of the fiddliest issues of php programming explained in the easiest way. Please don't ever stop teaching and record more courses
I really love the way you teach. Breaking the complex things into a small pieces of cake. Really enjoying.
You give amazing teacher vibes my man, everyone would be lucky to have you as a teacher!
The best explanation from the one of best tutors!
I always wanted to be like Jeffrey way 😀. The best explainer I have ever watched.
thank you laracast and Jeffrey Way for the professional presantation and deep explain of the best php course online!
This is by far the best explanation for service containers I have watched. Congrats on the video and the whole series.
Thank you Jeffrey. You are more than documentation. God bless you
Hey Jefferey. This is a phenomenal series. I’ve been coding since Jan 2020 and using Laravel since Jan 2021 and have just been rolling with and trusting the frame work. Now thanks to you I’m really starting to get it lol. Awesome man!!!!
Best php series on earth
Loving the series, I personally want to learn this kind of info than just to "enjoy" using frameworks without any knowledge of whats under the "hood". I think I will build one of my personal websites based on this knowledge. Thank you very much.
Great explainer for something I understand but have never needed to build. Feel better for knowing
These thumbnails match my first time getting into PHP and then hating life later on when I needed to refactor everything.
you are really amazing in delivering knowledge , THANK YOU 😊
I am happy I have found your channel
Thank you so much for this great lesson
It's incredibly easy and simple! now, I can understand app container! Thanks Jeffrey!
thank you
that's really amazing
you are really teaching us amazing concepts
I think the require base_path("Core/Validator.php"); was accidentally deleted at 17:45. But I guess the use Core\Validator automatically added by the PHPStorm.
I have learned a lot with how Jeffrey explains complex things. The only part I'm still confused or not fully grasp is how the other files have access to variables or classes through scope. I know you have required files which then whatever is in that file is accessible to the file below it but how I got stack with a routes. Can you explain the flow for me please?
Actually I love building things like routers and database handling myself. I find most frameworks are too huge and cumbersome for the small projects I usually make.
And it's a lot more fun to build it yourself, so you know how it works. This series is great in that regard.
I couldn't find this series on laracasts. Is it only available her on yt?
So looks like I was on the right path, but derailed along the way. Recently I made an Application class that instantiated a bunch of other classes inside of it - so in my pages I could access things like $App->Database->query() or $App->Router->loadController() .... etc..... I like the idea of having things accessible from a single "resource", and I'm glad that this is actually a "thing"... I just did it wrong. Thanks for the video... I still have to understand namespaces.
Yeah, and one of the nice things about the service container is that you only instantiate what you need when you need it, instead of everything upfront, which saves a bunch of CPU, memory and time.
@@travholt I see... well good thing I'm trying to correct my bad programming mistakes now. :)
Hi Jeff one more thing, i have followed others tut about intermediate PHP, in here i want to talk about router specifically. in that tut router just simply to say emulate get request and response to users if available and 404 if not. i was kind lost here about the concept in that tuts just matching request with controller if yes show the page associate with client req and 404 otherwise. one more thing. controller also have some method that match with SUBMIT_QUERY, while the class controller itself match with REQUEST_METHOD
Dear Jeffrey, help me understand the meaning of the App singleton if all its functionality can be left in the container and called static methods from there?
Maybe it's just sugar or has a specific practical meaning?
Jeffrey you are awesome👍
good job , thanks , at the begining of this playlist , all things great , becouse i know every step of what is going on at backend side of the any feramwork .
So if I understood correctly, here our Database class isn't a Singleton because each time we call our resolve class with the corresponding $Key, we keep on recreating the Database object to get access to it? Thanks
why did we use App class to initialize the container? why not just initialize it as a singleton inside itself?
Thank you for the gold info
at 11:30 you should also let people know that when you have something like a static property it can fill up in memory if you keep on pushing stuff to it, this could cause a memory leak if you use something such as Laravel Octane
Keep 'em coming
What phpstorm theme and color scheme is used in this video?
I'm lost halfway through the video. Gonna need to rewatch it.
Thank you Jeffrey
yeah i have to re-watch this 2 or 3 times 😅
Is this concept same as Dependancy Injection?
Many thanks for this, but I could not understand a point. destroy.php has $db object and it is creating with only App::revolve(Database::class). There is no any __constructors for container and app objects. so how can the app object create the container object ? maybe if I see sources i can make code review. While I watching I could not catch all process. will you put that small project on github?
Cause the App class contains static methods and the $container is a static property. static it means that you can use methods and properties directly without instantiating the class (you don't need a constructor). Usually static classes are often called utility classes referring to the fact that are used everywhere in your code.
At 11:18 Jeffrey starts building App class and he uses "static" property and method. This "static" is what enables you to access them without needing a __constructor. It was covered in previous episodes (cannot remember which one), but try re-watching that part as Jeffrey does explain it again.
You are right. all methods are static. I could not covered calling sequence while watching :). My problem is bindings. There is no binging and I think resolvers are calling bindings.
Bind is just a term, think about it like this, you have a box which contains key : value pairs where each bind is a "key" with a function as a "value". Whenever you want to add a pair to the box, you call the bind method, and whenever you want to use one of the function in the bindings, you call the "resolve" method. Is up to you what the resolve method does.
Hi, Bora. I upload the source code for every lesson to Laracasts. Just find the corresponding episode at phpforbeginners.com, and then scroll below the video for the Source Code link.
When did bootstrap work ? you skip it
i dont quite get it. what isnt the $db variable accessible already if you just instantiate it in index.php? then just call that in the child files
so good
where are you man wee miss you 10 days no videos
gotcha
Please make a tutorial on how to test with phpunit using database! thanks a lot
We have plenty of content like this at Laracasts.com.
Please go into DI using the service container. May a separate video
DI is a pretty loose term. Typically it means just passing in values to a constructor. So technically in this video Jeffrey was using DI to provide config values to the Database class.
Laravel takes DI a step further with autowiring which is made possible because of PHP's reflection API.
Basically autowiring works like this. High level methods (controllers, actions, jobs) are invoked by Higher-order Functions (HOF) aka decorators. The HOF inspects the target method's signature using reflection to get a list of wanted parameters. The parameters are resolved using a service container (like what Jeffrey wrote). Then the target method is invoked with a list of resolved variables.
But like he said, you wouldn't really want to implement all this yourself. You'd have to add a whole bunch of code to counteract the performance loss from reflection. My guess is you'd probably need some short circuiting and a caching layer.
None of that is super important though because you can reuse the HOF that I'm talking about in Laravel. Just use `App::call` to invoke a callable and autowiring will "just work". And, if you're not using Laravel, you can use Symfony's service container, or the PHP-DI library.
I'm not trying to hate, the video overall was very well presented and enjoyable but ... what problem does this exactly solve?
To me this seem like a global get_database function with extra steps + a possible missing-bind Exception?
The database resolver is just *one* piece that would go in the container. In real life, countless things would.
It's a very common pattern that countless applications use.
@@laracastsofficial I still don't know what problem that solves?
Why not just have a services.php file with get_service_a, get_service_b, get_service_c etc ... ?
You can if you want. Either way, you're wrapping the instantiation of an object within a function. How you trigger that function is up to you. But dozens of get_service_a(), get_service_b() functions doesn't sound very nice to me.
Also, like I mentioned at the end of the video, keep in mind that an off the shelf container supports so many other things, including singletons, automatic dependency tree resolution, interface binding, etc.
Additionally having a service container will ensure that all your services get to be instantiated once and have a single storage in memory which you can reference with each call to the specifc service. Having dozens of get_service_a(), get_service_b() functions means that you'll be calling the functions and returning new values each time they are defined in code which will eat up more memory. This may become a performance hit if you have a large application. The service container in this tutorial follows the singleton design pattern which is great for performance and code organization.
@@DanielGithinji1 Ahhhhh, yeah that makes sense, thnx
👍
I watched this many times because until I get the method chaining that confused me. It's about dependency injection or delegation.
Except 35 video (Service Container) i learnt a lot but i didn't understand service container properly 😔
pog
Send this wall paper to us (L)
typesafety 😔
Day one of begging Jeffrey to share his PHPStorm theme/color scheme 🤌
Carbon theme
Are you god? 🥲 thanks god