File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,18 @@ this works fine, controllers can also be specified as services.
15
15
primary advantage is that the entire controller or any services passed to
16
16
the controller can be modified via the service container configuration.
17
17
This is especially useful when developing an open-source bundle or any
18
- bundle that will be used in many different projects. So, even if you don't
19
- specify your controllers as services, you'll likely see this done in some
20
- open-source Symfony2 bundles.
18
+ bundle that will be used in many different projects.
19
+
20
+ A second advantage is that your controllers are more "sandboxed". By
21
+ looking at the constructor arguments, it's easy to see what types of things
22
+ this controller may or may not do. And because each dependency needs
23
+ to be injected manually, it's more obvious (i.e. if you have many constructor
24
+ arguments) when your controller has become too big, and may need to be
25
+ split into multiple controllers.
26
+
27
+ So, even if you don't specify your controllers as services, you'll likely
28
+ see this done in some open-source Symfony2 bundles. It's also important
29
+ to understand the pros and cons of both approaches.
21
30
22
31
Defining the Controller as a Service
23
32
------------------------------------
You can’t perform that action at this time.
0 commit comments