Skip to content

Commit 2a8a564

Browse files
committed
Merge branch '3.4'
* 3.4: more underlining! [#8571] Tweaks thanks to reviewers tweaked docs for Flex Update security.rst use .test instead of .dev as development domain updating controller scalar args for 3.4 Shortened command... easier to remember ;) Final updates Last fixes Restored the "Full Default Configuration" dump Fixed an indentation issue Simplified the framework configuration reference Added Doctrine entities and documents to the list of known locations for classes
2 parents a255be4 + 445a350 commit 2a8a564

File tree

7 files changed

+133
-106
lines changed

7 files changed

+133
-106
lines changed

bundles/best_practices.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,23 @@ files are going to be part of the repository.
115115
The following classes and files have specific emplacements (some are mandatory
116116
and others are just conventions followed by most developers):
117117

118-
=============================== ============================= ================
119-
Type Directory Mandatory?
120-
=============================== ============================= ================
121-
Commands ``Command/`` Yes
122-
Controllers ``Controller/`` No
123-
Service Container Extensions ``DependencyInjection/`` Yes
124-
Event Listeners ``EventListener/`` No
125-
Model classes [1] ``Model/`` No
126-
Configuration ``Resources/config/`` No
127-
Web Resources (CSS, JS, images) ``Resources/public/`` Yes
128-
Translation files ``Resources/translations/`` Yes
129-
Templates ``Resources/views/`` Yes
130-
Unit and Functional Tests ``Tests/`` No
131-
=============================== ============================= ================
132-
133-
[1] See :doc:`/doctrine/mapping_model_classes` for how to handle the
134-
mapping with a compiler pass.
118+
=================================================== ========================================
119+
Type Directory
120+
=================================================== ========================================
121+
Commands ``Command/``
122+
Controllers ``Controller/``
123+
Service Container Extensions ``DependencyInjection/``
124+
Doctrine ORM entities (when not using annotations) ``Entity/``
125+
Doctrine ODM documents (when not using annotations) ``Document/``
126+
Event Listeners ``EventListener/``
127+
Configuration ``Resources/config/``
128+
Web Resources (CSS, JS, images) ``Resources/public/``
129+
Translation files ``Resources/translations/``
130+
Validation (when not using annotations) ``Resources/config/validation/``
131+
Serialization (when not using annotations) ``Resources/config/serialization/``
132+
Templates ``Resources/views/``
133+
Unit and Functional Tests ``Tests/``
134+
=================================================== ========================================
135135

136136
Classes
137137
-------

controller.rst

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ command:
275275
276276
$ php bin/console debug:autowiring
277277
278-
If you need control over the *exact* value of an argument, you can override your
279-
controller's service config:
278+
If you need control over the *exact* value of an argument, you can :ref:`bind <services-binding>`
279+
the argument by its name:
280280

281281
.. configuration-block::
282282

@@ -289,13 +289,9 @@ controller's service config:
289289
# explicitly configure the service
290290
App\Controller\LuckyController:
291291
public: true
292-
tags:
293-
# add multiple tags to control multiple args
294-
- name: controller.service_arguments
295-
action: numberAction
296-
argument: logger
297-
# pass this specific service id
298-
id: monolog.logger.doctrine
292+
bind:
293+
# for any $logger argument, pass this specific service
294+
$logger: '@monolog.logger.doctrine'
299295
300296
.. code-block:: xml
301297
@@ -311,10 +307,8 @@ controller's service config:
311307
312308
<!-- Explicitly configure the service -->
313309
<service id="App\Controller\LuckyController" public="true">
314-
<tag
315-
name="controller.service_arguments"
316-
action="numberAction"
317-
argument="logger"
310+
<bind key="$logger"
311+
type="service"
318312
id="monolog.logger.doctrine"
319313
/>
320314
</service>
@@ -325,25 +319,25 @@ controller's service config:
325319
326320
// config/services.php
327321
use App\Controller\LuckyController;
322+
use Symfony\Component\DependencyInjection\Reference;
328323
329324
$container->register(LuckyController::class)
330325
->setPublic(true)
331-
->addTag('controller.service_arguments', [
332-
'action' => 'numberAction',
333-
'argument' => 'logger',
334-
'id' => 'monolog.logger.doctrine',
335-
])
326+
->setBindings(array(
327+
'$logger' => new Reference('monolog.logger.doctrine'),
328+
))
336329
;
337330
338331
You can of course also use normal :ref:`constructor injection <services-constructor-injection>`
339332
in your controllers.
340333

341334
.. caution::
342335

343-
You can *only* pass *services* to your controller arguments in this way. It's
344-
not possible, for example, to pass a service parameter as a controller argument.
345-
If you need a parameter, use the ``$this->getParameter('kernel.debug')`` shortcut
346-
or pass the value through your controller's ``__construct()`` method.
336+
You can *only* pass *services* to your controller arguments in this way. It's not
337+
possible, for example, to pass a service parameter as a controller argument,
338+
even by using ``bind``. If you need a parameter, use the ``$this->getParameter('kernel.debug')``
339+
shortcut or pass the value through your controller's ``__construct()`` method
340+
and specify its value with ``bind``.
347341

348342
For more information about services, see the :doc:`/service_container` article.
349343

reference/configuration/framework.rst

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@
44
FrameworkBundle Configuration ("framework")
55
===========================================
66

7-
The FrameworkBundle contains most of the "base" framework functionality
8-
and can be configured under the ``framework`` key in your application
9-
configuration. When using XML, you must use the
10-
``http://symfony.com/schema/dic/symfony`` namespace.
7+
The FrameworkBundle defines the main framework configuration, from sessions and
8+
translations to forms, validation, routing and more. All these options are
9+
configured under the ``framework`` key in your application configuration.
1110

12-
This includes settings related to sessions, translation, forms, validation,
13-
routing and more.
11+
.. code-block:: terminal
1412
15-
.. tip::
13+
# displays the default config values defined by Symfony
14+
$ php bin/console config:dump framework
15+
16+
# displays the actual config values used by your application
17+
$ php bin/console debug:config framework
18+
19+
.. note::
1620

17-
The XSD schema is available at
18-
``http://symfony.com/schema/dic/symfony/symfony-1.0.xsd``.
21+
When using XML, you must use the ``http://symfony.com/schema/dic/symfony``
22+
namespace and the related XSD schema is available at:
23+
``http://symfony.com/schema/dic/symfony/symfony-1.0.xsd``
1924

2025
Configuration
2126
-------------

security.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ To accomplish this you have 2 options:
993993
In both cases, you'll still deny access using methods similar to what was
994994
shown above.
995995

996-
Retrieving the User Object
997-
--------------------------
996+
3) Retrieving the User Object
997+
-----------------------------
998998

999999
After authentication, the ``User`` object of the current user can be accessed
10001000
via the ``security.token_storage`` service. From inside a controller, this will

service_container.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,13 @@ service whose id is ``monolog.logger.request``.
690690
the *service* whose id is ``monolog.logger.request``, and not just the *string*
691691
``monolog.logger.request``.
692692

693+
.. _services-binding:
694+
695+
Binding Arguments by Name or Type
696+
---------------------------------
697+
698+
You can also use the ``bind`` keyword to bind specific arguments by name or type.
699+
693700
.. _services-autowire:
694701

695702
The autowire Option

setup/flex.rst

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ Using Symfony Flex to Manage Symfony Applications
55

66
`Symfony Flex`_ is the new way to install and manage Symfony applications. Flex
77
is not a new Symfony version, but a tool that replaces and improves the
8-
`Symfony Installer`_.
8+
`Symfony Installer`_ and the `Symfony Standard Edition`_.
99

1010
Symfony Flex **automates the most common tasks of Symfony applications**, such
11-
as installing and removing bundles and other dependencies. Symfony Flex works
12-
for Symfony 3.3 and newer versions. Starting from Symfony 4.0, Flex will be used
13-
by default, but it will still be optional to use.
11+
as installing and removing bundles and other Composer dependencies. Symfony
12+
Flex works for Symfony 3.3 and newer versions. Starting from Symfony 4.0, Flex
13+
should be used by default, but it is still optional.
1414

1515
How Does Flex Work
1616
------------------
1717

1818
Internally, Symfony Flex is a Composer plugin that modifies the behavior of the
19-
``require`` and ``update`` commands. When installing or updating dependencies
20-
in a Flex-enabled application, Symfony can perform tasks before and after the
21-
execution of Composer tasks.
19+
``require``, ``update``, and ``remove`` commands. When installing or removing
20+
dependencies in a Flex-enabled application, Symfony can perform tasks before
21+
and after the execution of Composer tasks.
2222

2323
Consider the following example:
2424

@@ -33,25 +33,30 @@ name. However, if the application has Symfony Flex installed, that command ends
3333
up installing and enabling the SwiftmailerBundle, which is the best way to
3434
integrate Swiftmailer, the official mailer for Symfony applications.
3535

36-
When Symfony Flex is installed in the application and you execute ``composer require``,
37-
the application makes a request to Symfony Flex servers before trying to install
38-
the package with Composer:
36+
When Symfony Flex is installed in the application and you execute ``composer
37+
require``, the application makes a request to Symfony Flex servers before
38+
trying to install the package with Composer:
3939

4040
* If there's no information about that package, Flex server returns nothing and
4141
the package installation follows the usual procedure based on Composer;
42+
4243
* If there's special information about that package, Flex returns it in a file
43-
called "recipe" and the application uses it to decide which package to install
44-
and which automated tasks to run after the installation.
44+
called "recipe" and the application uses it to decide which package to
45+
install and which automated tasks to run after the installation.
4546

4647
In the above example, Symfony Flex asks about the ``mailer`` package and the
47-
Symfony Flex server detects that ``mailer`` is in fact an alias for SwiftmailerBundle
48-
and returns the "recipe" for it.
48+
Symfony Flex server detects that ``mailer`` is in fact an alias for
49+
SwiftmailerBundle and returns the "recipe" for it.
50+
51+
Flex keeps tracks of the recipes it installed in a ``symfony.lock`` file, which
52+
must be committed to your code repository.
4953

5054
Symfony Flex Recipes
5155
~~~~~~~~~~~~~~~~~~~~
5256

5357
Recipes are defined in a ``manifest.json`` file and can contain any number of
54-
other files and directories. For example, this is the ``manifest.json`` for SwiftmailerBundle:
58+
other files and directories. For example, this is the ``manifest.json`` for
59+
SwiftmailerBundle:
5560

5661
.. code-block:: javascript
5762
@@ -69,27 +74,29 @@ other files and directories. For example, this is the ``manifest.json`` for Swif
6974
}
7075
7176
The ``aliases`` option allows Flex to install packages using short and easy to
72-
remember names (``composer require mailer`` vs ``composer require symfony/swiftmailer-bundle``).
73-
The ``bundles`` option tells Flex in which environments should this bundle be
74-
enabled automatically (``all`` in this case). The ``env`` option makes Flex to
75-
add new environment variables to the application. Finally, the ``copy-from-recipe``
76-
option allows the recipe to copy files and directories into your application.
77-
78-
The instructions defined in this ``manifest.json`` file are also used by Symfony
79-
Flex when uninstalling dependencies (e.g. ``composer remove mailer``) to undo
80-
all changes. This means that Flex can remove the SwiftmailerBundle from the
81-
application, delete the ``MAILER_URL`` environment variable and any other file
82-
and directory created by this recipe.
77+
remember names (``composer require mailer`` vs ``composer require
78+
symfony/swiftmailer-bundle``). The ``bundles`` option tells Flex in which
79+
environments this bundle should be enabled automatically (``all`` in this
80+
case). The ``env`` option makes Flex to add new environment variables to the
81+
application. Finally, the ``copy-from-recipe`` option allows the recipe to copy
82+
files and directories into your application.
83+
84+
The instructions defined in this ``manifest.json`` file are also used by
85+
Symfony Flex when uninstalling dependencies (e.g. ``composer remove mailer``)
86+
to undo all changes. This means that Flex can remove the SwiftmailerBundle from
87+
the application, delete the ``MAILER_URL`` environment variable and any other
88+
file and directory created by this recipe.
8389

8490
Symfony Flex recipes are contributed by the community and they are stored in
8591
two public repositories:
8692

8793
* `Main recipe repository`_, is a curated list of recipes for high quality and
8894
maintained packages. Symfony Flex only looks in this repository by default.
89-
* `Contrib recipe repository`_, contains all the recipes created by the community.
90-
All of them are guaranteed to work, but their associated packages could be
91-
unmaintained. Symfony Flex ignores these recipes by default, but you can execute
92-
this command to start using them in your project:
95+
96+
* `Contrib recipe repository`_, contains all the recipes created by the
97+
community. All of them are guaranteed to work, but their associated packages
98+
could be unmaintained. Symfony Flex ignores these recipes by default, but you
99+
can execute this command to start using them in your project:
93100

94101
.. code-block:: terminal
95102
@@ -103,9 +110,9 @@ Using Symfony Flex in New Applications
103110
--------------------------------------
104111

105112
Symfony has published a new "skeleton" project, which is a minimal Symfony
106-
project recommended to create new applications. This "skeleton" already includes
107-
Symfony Flex as a dependency, so you can create a new Flex-enabled Symfony
108-
application executing the following command:
113+
project recommended to create new applications. This "skeleton" already
114+
includes Symfony Flex as a dependency. This means you can create a new Flex-enabled
115+
Symfony application by executing the following command:
109116

110117
.. code-block:: terminal
111118
@@ -114,7 +121,8 @@ application executing the following command:
114121
.. note::
115122

116123
The use of the Symfony Installer to create new applications is no longer
117-
recommended since Symfony 3.3. Use Composer ``create-project`` command instead.
124+
recommended since Symfony 3.3. Use Composer ``create-project`` command
125+
instead.
118126

119127
Upgrading Existing Applications to Flex
120128
---------------------------------------
@@ -144,29 +152,42 @@ following directory structure, which is the same used by default in Symfony 4:
144152
145153
This means that installing the ``symfony/flex`` dependency in your application
146154
is not enough. You must also upgrade the directory structure to the one showed
147-
above. Sadly, there's no automatic tool to make this upgrade, so you must follow
148-
these manual steps:
149-
150-
#. Create a new empty Symfony application (``composer create-project symfony/skeleton my-project-flex``)
151-
#. Copy the ``require`` and ``require-dev`` dependencies defined in your original
152-
project's ``composer.json`` file to the ``composer.json`` file of the new project.
153-
#. Install the dependencies in the new project executing ``composer install``. This
154-
will make Symfony Flex generate all the configuration files in ``config/packages/``
155+
above. There's no automatic tool to make this upgrade, so you must follow these
156+
manual steps:
157+
158+
#. Create a new empty Symfony application (``composer create-project
159+
symfony/skeleton my-project-flex``)
160+
161+
#. Merge the ``require`` and ``require-dev`` dependencies defined in your
162+
original project's ``composer.json`` file to the ``composer.json`` file of the
163+
new project (don't copy the ``symfony/symfony`` dependency, but add the
164+
relevant components you are effectively using in your project).
165+
166+
#. Install the dependencies in the new project executing ``composer install``.
167+
This will make Symfony Flex generate all the configuration files in
168+
``config/packages/``
169+
155170
#. Review the generated ``config/packages/*.yaml`` files and make any needed
156-
changes according to the configuration defined in the ``app/config/config_*.yml``
157-
file of your original project. Beware that this is the most time-consuming
158-
and error-prone step of the upgrade process.
159-
#. Move the original parameters defined in ``app/config/parameters.*.yml`` to the
160-
new ``config/services.yaml`` and ``.env`` files depending on your needs.
171+
changes according to the configuration defined in the
172+
``app/config/config_*.yml`` file of your original project. Beware that this is
173+
the most time-consuming and error-prone step of the upgrade process.
174+
175+
#. Move the original parameters defined in ``app/config/parameters.*.yml`` to
176+
the new ``config/services.yaml`` and ``.env`` files depending on your needs.
177+
161178
#. Move the original source code from ``src/{App,...}Bundle/`` to ``src/`` and
162-
update the namespaces of every PHP file (advanced IDEs can do this automatically).
163-
#. Move the original templates from ``templates/`` to ``templates/``
164-
#. Make any other change needed by your application. For example, if your original
165-
``public/app_*.php`` front controllers were customized, add those changes to the
166-
new ``public/index.php`` controller.
179+
update the namespaces of every PHP file (advanced IDEs can do this
180+
automatically).
181+
182+
#. Move the original templates from ``app/Resources/views/`` to ``templates/``
183+
184+
#. Make any other change needed by your application. For example, if your
185+
original ``web/app_*.php`` front controllers were customized, add those changes
186+
to the new ``public/index.php`` controller.
167187

168188
.. _`Symfony Flex`: https://github.com/symfony/flex
169189
.. _`Symfony Installer`: https://github.com/symfony/symfony-installer
190+
.. _`Symfony Standard Edition`: https://github.com/symfony/symfony-standard
170191
.. _`Main recipe repository`: https://github.com/symfony/recipes
171192
.. _`Contrib recipe repository`: https://github.com/symfony/recipes-contrib
172193
.. _`Symfony Recipes documentation`: https://github.com/symfony/recipes/blob/master/README.rst

setup/homestead.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ configuration:
4848
4949
# ...
5050
sites:
51-
- map: symfony-demo.dev
51+
- map: symfony-demo.test
5252
to: /home/vagrant/projects/symfony_demo/web
5353
type: symfony
5454
5555
The ``type`` option tells Homestead to use the Symfony nginx configuration.
5656

57-
At last, edit the hosts file on your local machine to map ``symfony-demo.dev``
57+
At last, edit the hosts file on your local machine to map ``symfony-demo.test``
5858
to ``192.168.10.10`` (which is the IP used by Homestead)::
5959

6060
# /etc/hosts (unix) or C:\Windows\System32\drivers\etc\hosts (Windows)
61-
192.168.10.10 symfony-demo.dev
61+
192.168.10.10 symfony-demo.test
6262

63-
Now, navigate to ``http://symfony-demo.dev`` in your web browser and enjoy
63+
Now, navigate to ``http://symfony-demo.test`` in your web browser and enjoy
6464
developing your Symfony application!
6565

6666
.. seealso::

0 commit comments

Comments
 (0)