Dependency Injection in PHP | Create a Service Container from Scratch | Use PHP-DI

preview_player
Показать описание
Learn what dependency injection is, and how to do it in PHP.

Topics covered:
• Dependency injection
• Service containers
• Autowiring
• Third-party DI containers like PHP-DI

All source code shown is free to download:

Links shown in the video:

Videos:
‣ Securely Storing PHP Configuration Settings

Image used in thumbnail:

00:00 Introduction
00:22 What is dependency injection?
03:46 Create a DI container
05:27 Autowiring
11:00 Defining services
13:52 Use PHP-DI
15:48 Summary

#PHP #dependencyinjection #laravel #symfony
Рекомендации по теме
Комментарии
Автор

The way you explain such complicated topics is amazing 👏🏾

danimatuko
Автор

Great Teacher!
I have 4 Udemy courses from him!
He Masters PHP! 😎👍

someutubchannel
Автор

Absolutely perfect! Thank you so much for helping me truly grasp DI in the right way.

yhaouatis
Автор

At Uni I chose to do a Developmental project and it was building a web service for an MSc course. I enrolled in Dave's API course on Udemy. The webs service was being consumed by Embassy websites. I tried several courses on Udemy and other sites only Dave's API course was helpful. It was also the shortest yet it covered everything I needed including detailed JWT Authentication. Dave's understanding of PHP is amazing, I guess he now dreams in PHP.

AndrewKwabula
Автор

This is the best 👌, never heard anything better. I guess people are the reason why everything sounds very complicated.

awabomer
Автор

This was great and amazingly well explained. I previously didn't understood so much the idea behind dependency injection, but with this video is much more clear now. Thanks again Dave!

edopenroz
Автор

The PHP 🧙‍♂ wizard as always to the point with simple explanations. Loved it. Thank you.

iam.masoudsamimi
Автор

This is exactly what I've been struggling with to understand, thank you so much. Great explanation.

Nomad-mfpn
Автор

Excellent instructor and clearly very competent on the subject matter.
Please consider a course on using/accessing.a PHP application with SSO/Entra.

dannymason
Автор

What a great video. such way to explain the topic, amazing job

brunoggdev
Автор

Absolutely well done! Start with the most basic, then roll into an actual framework. I guess this shows the power of the prs-11 convention?

Paretozen
Автор

thank you for create quality content and way you explain. keep it up

shashikantmarskole
Автор

Lots of very good content on your channel, i also checked the paid courses and will buy them, but i couldn't find any course on how to develop a multi env app like "staging" and "prod", "testing" i think this should be the next topic

awabomer
Автор

HI, the simplest and best explanation. Thanks.
Now is missing a video about php as template system like plates, how organize using section / blocks or template Inheritance and base layouts.
Please update your PHP unit course, which i already bought, to v10.
And if possible, do first a video (overview) about Pest lib for testing and later on a full course on udemy. Thanks.

jediampm
Автор

Thank you Dave. That was magnificent. I wish that your words during your presentation are captured as comments for each line.

May I ask? The way you structured your psr-4 autoload setting: "": "sec/", will it still work if your Classes had namespaces?

NedumEze
Автор

Am understanding it but its challenging to find utility in my projects.
Am thinking i should learn a bit bout Design pattern first like factory, singleton etc .

ArsNoble
Автор

Thank you Dave for all your tutorials. Do you have or plan for a Laravel tutorial?
Are there any new full tutorial coming? and thanks again

alalyrealestate
Автор

hi @dave may i know what Text editor you are using ??

Alleo-zlfp
Автор

Hello Dave,
I am still getting the Error: Uncaught ReflectionException: Class "string" does not exist.
But then I realizing that my DAO class has a parameter with type PDO instead of the Database object, after I change the parameter type to database class object, it worked.
But in cases like this where we just need to pass a method (returns the connection object) in the constructor is there a way to handle this with DI container? or is that even a good practice?

ll
Автор

Hi, I wanted to ask a question, how do I resolve classes through DI that need runtime parameters?

For example, if I have a UserService that in it's constructor will accept a User Model (say a User in Laravel), how do I inject this UserService as a dependency?
I was thinking maybe I can have a setter injection instead of a constructor so that wherever I inject the class as a dependency itself, I call it's setter method to set the User for that UserService and then go through the logic I need to go through, is this a smart idea?

tariksadiku
join shbcf.ru