@@ -24,6 +24,7 @@ the alphabet.
2424
2525Start by creating a ROT13 transformer class::
2626
27+ // src/Util/Rot13Transformer.php
2728 namespace App\Util;
2829
2930 class Rot13Transformer
@@ -36,6 +37,7 @@ Start by creating a ROT13 transformer class::
3637
3738And now a Twitter client using this transformer::
3839
40+ // src/Service/TwitterClient.php
3941 namespace App\Service;
4042
4143 use App\Util\Rot13Transformer;
@@ -122,6 +124,7 @@ both services:
122124
123125 Now, you can use the ``TwitterClient `` service immediately in a controller::
124126
127+ // src/Controller/DefaultController.php
125128 namespace App\Controller;
126129
127130 use App\Service\TwitterClient;
@@ -153,6 +156,9 @@ Autowiring Logic Explained
153156
154157Autowiring works by reading the ``Rot13Transformer `` *type-hint * in ``TwitterClient ``::
155158
159+ // src/Service/TwitterClient.php
160+ namespace App\Service;
161+
156162 // ...
157163 use App\Util\Rot13Transformer;
158164
@@ -277,6 +283,7 @@ of concrete classes as it replaces your dependencies with other objects.
277283
278284To follow this best practice, suppose you decide to create a ``TransformerInterface ``::
279285
286+ // src/Util/TransformerInterface.php
280287 namespace App\Util;
281288
282289 interface TransformerInterface
@@ -376,6 +383,7 @@ Dealing with Multiple Implementations of the Same Type
376383Suppose you create a second class - ``UppercaseTransformer `` that implements
377384``TransformerInterface ``::
378385
386+ // src/Util/UppercaseTransformer.php
379387 namespace App\Util;
380388
381389 class UppercaseTransformer implements TransformerInterface
@@ -404,6 +412,7 @@ create a *named autowiring alias* from a special string containing the
404412interface followed by a variable name matching the one you use when doing
405413the injection::
406414
415+ // src/Service/MastodonClient.php
407416 namespace App\Service;
408417
409418 use App\Util\TransformerInterface;
@@ -546,6 +555,7 @@ When autowiring is enabled for a service, you can *also* configure the container
546555to call methods on your class when it's instantiated. For example, suppose you want
547556to inject the ``logger `` service, and decide to use setter-injection::
548557
558+ // src/Util/Rot13Transformer.php
549559 namespace App\Util;
550560
551561 class Rot13Transformer
0 commit comments