Skip to content

Commit 229f9bd

Browse files
Replace service name with FQCN class reference
As there isn't any mention of `app.hello_controller` (no definition) and the previous chapter mentioned using the FQCN is what Symfony recommends (it eases refactoring, especially for `php` configuration) it makes much more sense to make use of the FQCN as the service identifier. And lined up the `yaml`-config (as done in the rest of the documentation; routing chapter)
1 parent b604dc1 commit 229f9bd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

controller/service.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ a service like: ``App\Controller\HelloController::index``:
100100
101101
# config/routes.yaml
102102
hello:
103-
path: /hello
103+
path: /hello
104104
controller: App\Controller\HelloController::index
105-
methods: GET
105+
methods: GET
106106
107107
.. code-block:: xml
108108
@@ -181,8 +181,8 @@ which is a common practice when following the `ADR pattern`_
181181
182182
# config/routes.yaml
183183
hello:
184-
path: /hello/{name}
185-
controller: app.hello_controller
184+
path: /hello/{name}
185+
controller: App\Controller\HelloController
186186
187187
.. code-block:: xml
188188
@@ -194,16 +194,18 @@ which is a common practice when following the `ADR pattern`_
194194
https://symfony.com/schema/routing/routing-1.0.xsd">
195195
196196
<route id="hello" path="/hello/{name}">
197-
<default key="_controller">app.hello_controller</default>
197+
<default key="_controller">App\Controller\HelloController</default>
198198
</route>
199199
200200
</routes>
201201
202202
.. code-block:: php
203203
204+
use App\Controller\HelloController;
205+
204206
// app/config/routing.php
205207
$collection->add('hello', new Route('/hello', [
206-
'_controller' => 'app.hello_controller',
208+
'_controller' => HelloController::class,
207209
]));
208210
209211
Alternatives to base Controller Methods

0 commit comments

Comments
 (0)