File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 3
3
require __DIR__ . '/vendor/autoload.php ' ;
4
4
5
5
6
- // create DI container
6
+ // Set up the Dependency Injection container with auto-rebuild enabled
7
+ // The auto-rebuild feature ensures the container is regenerated when changes are detected
7
8
$ loader = new Nette \DI \ContainerLoader (__DIR__ . '/temp ' , autoRebuild: true );
9
+
10
+ // Load the configuration and create the DI container class
8
11
$ class = $ loader ->load (function ($ compiler ) {
9
- $ compiler ->loadConfig (__DIR__ . '/config.neon ' );
12
+ $ compiler ->loadConfig (__DIR__ . '/config.neon ' );
10
13
});
14
+
15
+
16
+ // Instantiate the DI container
11
17
$ container = new $ class ;
12
18
13
19
14
- // my application
15
- $ manager = $ container ->getByType (' NewsletterManager ' );
20
+ // Fetch the 'NewsletterManager' service from the DI container and run the distribution
21
+ $ manager = $ container ->getByType (NewsletterManager::class );
16
22
$ manager->
distribute ([
'[email protected] ' ]);
You can’t perform that action at this time.
0 commit comments