Dependency Injection in Slim - The ULTIMATE Web-API course with PHP & Slim [Ep. 005]
In this episode i will show you how you can easily use a very important programming concept called "dependency injection" in your Slim web API's. You will learn how you can setup your own dependency injection container with PHP-DI and how to register custom dependencies with different methods like autowiring, etc. Then i will show you how to inject those dependencies in your services and controllers. We will also focus on restructuring our app.
đ Website:
https://robbelroot.de
đ Official Documentations:
https://php-di.org/
https://www.slimframework.com/docs/v4
đ Chapters
00:15 Recap of last episode
02:11 Todays topic - DI
02:31 A general DI explanation
03:14 Another concept - IoC
03:52 Why DI
04:24 Into the Slim app
04:55 Fixing known WinNMP errors
06:26 Installing Slim http implementation
06:51 Basic Slim setup
07:53 Setting up DI with php-di
08:35 Fixing php-di composer error
10:09 Creating dependencies.php file
11:48 Creating an example service
12:55 Adding a dependency definition
14:09 Not nice
16:18 More explanation on DI
18:11 Rely on abstractions not implementations
19:37 Restructuring our app
25:31 Autowiring dependencies
HASHTAGS: #slim #php #dependencyinjection #framework #webprogramming #programming #tutorial