@@ -23,17 +23,19 @@ These are the main **advantages** of defining controllers as services:
2323 service container configuration. This is useful when developing reusable bundles;
2424* Your controllers are more "sandboxed". By looking at the constructor arguments,
2525 it's easy to see what types of things this controller may or may not do;
26+ * If you're not passing some required dependencies or if you are injecting some
27+ non-existent services, you'll get errors during the container compilation
28+ instead of during runtime execution;
2629* Since dependencies must be injected manually, it's more obvious when your
2730 controller is becoming too big (i.e. if you have many constructor arguments).
2831
2932These are the main **drawbacks ** of defining controllers as services:
3033
31- * It takes more work to create the controllers because they don't have
32- automatic access to the services or to the base controller shortcuts;
34+ * It takes more work to create the controllers and they become more verbose
35+ because they don't have automatic access to the services and the base
36+ controller shortcuts;
3337* The constructor of the controllers can rapidly become too complex because you
34- must inject every single dependency needed by them;
35- * The code of the controllers is more verbose because you can't use the shortcuts
36- of the base controller and you must replace them with some lines of code.
38+ must inject every single dependency needed by them.
3739
3840The recommendation from the :doc: `best practices </best_practices/controllers >`
3941is also valid for controllers defined as services: avoid putting your business
0 commit comments