@@ -8,19 +8,19 @@ without sacrificing predictability, which is very important! Another goal is to
88controllers and services behave more consistently. In Symfony 3.3, controllers *are *
99services by default.
1010
11- The documentation has already been updated to assume you have these new features enabled.
12- If you're an existing Symfony user and want to understand the "what" and "why" behind
13- these changes, this chapter is for you!
11+ The documentation has already been updated to assume you have these new features
12+ enabled. If you're an existing Symfony user and want to understand the "what"
13+ and "why" behind these changes, this article is for you!
1414
15- All Changes are Opt-In
16- ----------------------
15+ All Changes are Optional
16+ ------------------------
1717
1818Most importantly, **you can upgrade to Symfony 3.3 today without making any changes to your app **.
1919Symfony has a strict :doc: `backwards compatibility promise </contributing/code/bc >`,
2020which means it's always safe to upgrade across minor versions.
2121
22- All of the new features are **opt-in **: you need to actually change your configuration
23- files to use them.
22+ All of the new features are **optional **: they are not enabled by default, so you
23+ need to actually change your configuration files to use them.
2424
2525The new Default services.yml File
2626---------------------------------
@@ -151,7 +151,7 @@ thanks to the following config:
151151 // services cannot be automatically loaded with PHP configuration
152152 // you need to define your services one-by-one
153153
154- This means that every class in ``src/AppBundle `` is *available * to be used as a
154+ This means that every class in ``src/AppBundle/ `` is *available * to be used as a
155155service. And thanks to the ``_defaults `` section at the top of the file, all of
156156these services are **autowired ** and **private ** (i.e. ``public: false ``).
157157
@@ -166,7 +166,7 @@ to determine most arguments automatically. But, you can always override the serv
166166and :ref: `manually configure arguments <services-manually-wire-args >` or anything
167167else special about your service.
168168
169- But wait, if I have some model (non-service) classes in my ``src/AppBundle ``
169+ But wait, if I have some model (non-service) classes in my ``src/AppBundle/ ``
170170 directory, doesn't this mean that *they * will also be registered as services?
171171 Isn't that a problem?
172172
@@ -230,12 +230,12 @@ To pass the ``InvoiceGenerator`` as an argument to ``InvoiceMailer``, you needed
230230to specify the service's *id * as an argument: ``app.invoice_generator ``. Service
231231id's were the main way that you configured things.
232232
233- But in Symfony 3.3, thanks to autowiring, all you need to do is type-hint the argument
234- with ``InvoiceGenerator ``::
233+ But in Symfony 3.3, thanks to autowiring, all you need to do is type-hint the
234+ argument with ``InvoiceGenerator ``::
235235
236236 // src/AppBundle/Service/InvoiceMailer.php
237237 // ...
238-
238+
239239 class InvoiceMailer
240240 {
241241 private $generator;
@@ -288,7 +288,7 @@ was designed with that in mind. Specifically:
288288 a service whose id matches the type-hint exactly. It does *not * scan all services
289289 looking for objects that have that class/interface (actually, it *does * do this
290290 in Symfony 3.3, but has been deprecated. If you rely on this, you will see a clear
291- deprecation warning).
291+ deprecation warning).
292292
293293Autowiring aims to *automate * configuration without magic.
294294
@@ -387,7 +387,7 @@ create the class::
387387
388388 // src/AppBundle/EventSubscriber/SetHeaderSusbcriber.php
389389 // ...
390-
390+
391391 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
392392 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
393393 use Symfony\Component\HttpKernel\KernelEvents;
@@ -398,7 +398,7 @@ create the class::
398398 {
399399 $event->getResponse()->headers->set('X-SYMFONY-3.3', 'Less config');
400400 }
401-
401+
402402 public static function getSubscribedEvents()
403403 {
404404 return [
@@ -499,8 +499,8 @@ Start by adding a ``_defaults`` section with ``autowire`` and ``autoconfigure``.
499499 # ...
500500
501501 This step is easy: you're already *explicitly * configuring all of your services.
502- So, ``autowire `` does nothing. You're also already tagging your services, so `` autoconfigure ``
503- also doesn't change any existing services.
502+ So, ``autowire `` does nothing. You're also already tagging your services, so
503+ `` autoconfigure `` also doesn't change any existing services.
504504
505505You have not added ``public: false `` yet. That will come in a minute.
506506
@@ -574,7 +574,7 @@ Now you're ready to default all services to be private:
574574
575575 # app/config/services.yml
576576 # ...
577-
577+
578578 services:
579579 _defaults:
580580 autowire: true
@@ -592,7 +592,7 @@ instances of the same class), you may need to make those public:
592592
593593 # app/config/services.yml
594594 # ...
595-
595+
596596 services:
597597 # ...
598598
@@ -602,7 +602,7 @@ instances of the same class), you may need to make those public:
602602 + # remove this if/when you are not fetching this
603603 + # directly from the container via $container->get()
604604 + public: true
605-
605+
606606 app.api_client_sl_connect:
607607 # ...
608608 + public: true
@@ -614,8 +614,8 @@ clean that up.
614614Step 4) Auto-registering Services
615615~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
616616
617- You're now ready to automatically register all services in ``src/AppBundle `` (and/or
618- any other directory/bundle you have):
617+ You're now ready to automatically register all services in ``src/AppBundle/ ``
618+ (and/or any other directory/bundle you have):
619619
620620.. code-block :: diff
621621
@@ -697,7 +697,7 @@ these directly from the container, you can remove the ``public: true`` flag:
697697 app.api_client_github:
698698 # ...
699699 - public: true
700-
700+
701701 app.api_client_sl_connect:
702702 # ...
703703 - public: true
0 commit comments