Skip to content

Commit 8ee9fec

Browse files
committed
added comments to the code
1 parent b57738d commit 8ee9fec

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

example.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
require __DIR__ . '/vendor/autoload.php';
44

55

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
78
$loader = new Nette\DI\ContainerLoader(__DIR__ . '/temp', autoRebuild: true);
9+
10+
// Load the configuration and create the DI container class
811
$class = $loader->load(function($compiler) {
9-
$compiler->loadConfig(__DIR__ . '/config.neon');
12+
$compiler->loadConfig(__DIR__ . '/config.neon');
1013
});
14+
15+
16+
// Instantiate the DI container
1117
$container = new $class;
1218

1319

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);
1622
$manager->distribute(['[email protected]']);

0 commit comments

Comments
 (0)