Skip to content

Commit 7946db7

Browse files
committed
Fixes spotted by reviewers
1 parent 2f45ec2 commit 7946db7

File tree

2 files changed

+32
-46
lines changed

2 files changed

+32
-46
lines changed

configuration.rst

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ there's not even any performance difference between them.
6767
YAML is used by default when installing packages because it's concise and very
6868
readable. These are the main advantages and disadvantages of each format:
6969

70-
* **YAML**: simple, clean and readable, but requires using a dedicated parser.
71-
:doc:`Learn the YAML syntax </components/yaml/yaml_format>`;
72-
* **XML**: supports IDE autocompletion/validation and is parsed natively by PHP,
70+
* **YAML**: simple, clean and readable, but not all IDEs support autocompletion
71+
and validation for it. :doc:`Learn the YAML syntax </components/yaml/yaml_format>`;
72+
* **XML**:autocompleted/validated by most IDEs and is parsed natively by PHP,
7373
but sometimes it generates too verbose configuration. `Learn the XML syntax`_;
7474
* **PHP**: very powerful and it allows to create dynamic configuration, but the
7575
resulting configuration is less readable than the other formats.
@@ -603,23 +603,9 @@ will load the parsed file instead of parsing the ``.env`` files again:
603603

604604
.. _configuration-env-var-web-server:
605605

606-
Using ``.env`` files is the recommended way of using env vars in Symfony
607-
applications. However, you can also define env vars in the web server
608-
configuration if you prefer that:
609-
610-
.. configuration-block::
611-
612-
.. code-block:: apache
613-
614-
<VirtualHost *:80>
615-
# ...
616-
617-
SetEnv DATABASE_URL "mysql://db_user:db_password@127.0.0.1:3306/db_name"
618-
</VirtualHost>
619-
620-
.. code-block:: nginx
621-
622-
fastcgi_param DATABASE_URL "mysql://db_user:db_password@127.0.0.1:3306/db_name";
606+
Creating ``.env`` files is the easiest way of using env vars in Symfony
607+
applications. However, you can also configure real env vars in your servers and
608+
operating systems.
623609

624610
.. tip::
625611

@@ -643,30 +629,33 @@ Managing Multiple .env Files
643629
The ``.env`` file defines the default values for all env vars. However, it's
644630
common to override some of those values depending on the environment (e.g. to
645631
use a different database for tests) or depending on the machine (e.g. to use a
646-
different OAuth token in your local machine while developing).
632+
different OAuth token on your local machine while developing).
647633

648634
That's why you can define multiple ``.env`` files to override env vars. The
649635
following list shows the files loaded in all environments. The ``.env`` file is
650-
the only mandatory file and each file overrides all the previous ones:
636+
the only mandatory file and each file content overrides the previous one:
651637

652638
* ``.env``: defines the default values of the env vars needed by the application;
653-
* ``.env.local``: overrides env vars for all environments but only in your local
654-
machine;
655-
* ``.env.<environment>`` (e.g. ``.env.test``): overrides env vars for some
656-
environment and for all machines;
657-
* ``.env.<environment>.local`` (e.g. ``.env.test.local``): overrides env vars
658-
only for some environment and only in your local machine.
639+
* ``.env.local``: defines machine-specific overrides for env vars on all
640+
environments. This file is not committed to the repository, so these overrides
641+
only apply to the machine which contains the file (your local computer,
642+
production server, etc.);
643+
* ``.env.<environment>`` (e.g. ``.env.test``): overrides env vars only for some
644+
environment but for all machines;
645+
* ``.env.<environment>.local`` (e.g. ``.env.test.local``): defines machine-specific
646+
env vars overrides only for some environment. It's similar to ``.env.local``,
647+
but the overrides only apply to some particular environment.
659648

660649
.. note::
661650

662651
The real environment variables defined in the server always win over the
663652
env vars created by the ``.env`` files.
664653

665654
The ``.env`` and ``.env.<environment>`` files should be committed to the shared
666-
repository because they are the same for all developers. However, the env files
667-
ending in ``.local`` (``.env.local`` and ``.env.<environment>.local``) **should
668-
not be committed** because only you will use them. In fact, the ``.gitignore``
669-
file that comes with Symfony prevents them from being committed.
655+
repository because they are the same for all developers and machines. However,
656+
the env files ending in ``.local`` (``.env.local`` and ``.env.<environment>.local``)
657+
**should not be committed** because only you will use them. In fact, the
658+
``.gitignore`` file that comes with Symfony prevents them from being committed.
670659

671660
.. caution::
672661

@@ -677,18 +666,18 @@ file that comes with Symfony prevents them from being committed.
677666
Accessing Configuration Values
678667
------------------------------
679668

680-
Controllers and services can access to all the configuration parameters. This
681-
includes both the :ref:`parameteres defined by yourself <configuration-parameters>`
669+
Controllers and services can access all the configuration parameters. This
670+
includes both the :ref:`parameters defined by yourself <configuration-parameters>`
682671
and the parameters created by packages/bundles. Run the following command to see
683672
all the parameters that exist in your application:
684673

685674
.. code-block:: terminal
686675
687676
$ php bin/console debug:container --parameters
688677
689-
Parameters are injected in services as arguments of their constructors.
678+
Parameters are injected in services as arguments to their constructors.
690679
:doc:`Service autowiring </service_container/autowiring>` doesn't work for
691-
parameters, so you must inject them explicitly:
680+
parameters. Instead, inject them explicitly:
692681

693682
.. configuration-block::
694683

@@ -737,8 +726,8 @@ parameters, so you must inject them explicitly:
737726
If you inject the same parameters over and over again, use instead the
738727
``services._defaults.bind`` option. The arguments defined in that option are
739728
injected automatically whenever a service constructor or controller action
740-
define an argument with that exact name. For example, if you want to inject the
741-
value of the :ref:`kernel.project_dir parameter <configuration-kernel-project-directory>`
729+
define an argument with that exact name. For example, to inject the value of the
730+
:ref:`kernel.project_dir parameter <configuration-kernel-project-directory>`
742731
whenever a service/controller defines a ``$projectDir`` argument, use this:
743732

744733
.. configuration-block::
@@ -799,28 +788,25 @@ whenever a service/controller defines a ``$projectDir`` argument, use this:
799788
Finally, if some service needs to access to lots of parameters, instead of
800789
injecting each of them individually, you can inject all the application
801790
parameters at once by type-hinting any of its constructor arguments with the
802-
:class:`Symfony\\Component\\DependencyInjection\\ParameterBag\\ParameterBagInterface`
803-
or the new :class:`Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface`.
804-
However, in these cases it's usually better to refactor the service and avoid
805-
requiring so many parameters::
791+
:class:`Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface`::
806792

807793
// src/Service/MessageGenerator.php
808794
// ...
809795

810-
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
796+
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
811797

812798
class MessageGenerator
813799
{
814800
private $params;
815801

816-
public function __construct(ParameterBagInterface $params)
802+
public function __construct(ContainerBagInterface $params)
817803
{
818804
$this->params = $params;
819805
}
820806

821807
public function someMethod()
822808
{
823-
// get any param from $this->params, which stores all container parameters
809+
// get any container parameter from $this->params, which stores all of them
824810
$sender = $this->params->get('mailer_sender');
825811
// ...
826812
}

service_container.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ accessor methods for parameters::
532532

533533
.. note::
534534

535-
You can only set a parameter before the container is compiled: not at run-time.
535+
You can only set a parameter before the container is compiled, not at run-time.
536536
To learn more about compiling the container see
537537
:doc:`/components/dependency_injection/compilation`.
538538

0 commit comments

Comments
 (0)