Skip to content

Commit 1e09261

Browse files
committed
More changes after reviews
1 parent f1ef183 commit 1e09261

File tree

1 file changed

+15
-46
lines changed

1 file changed

+15
-46
lines changed

best_practices.rst

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,14 @@ to create new Symfony applications:
3232
$ symfony new my_project_name
3333
3434
Under the hood, this Symfony binary command executes the needed `Composer`_
35-
command to create a new Symfony application based on the current stable version.
35+
command to :ref:`create a new Symfony application <creating-symfony-applications>`
36+
based on the current stable version.
3637

37-
Use the Symfony Skeleton to Create New Symfony-based Projects
38-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39-
40-
Symfony provides two "skeletons" (or "project templates") to
41-
:ref:`create new Symfony projects <creating-symfony-applications>`. Use the
42-
minimal "skeleton" to start small and get the best performance and grow your
43-
application later as needed.
44-
45-
Use Composer and Symfony Flex to Manage Symfony Applications
46-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47-
48-
`Composer`_ is the package manager used by modern PHP applications to manage
49-
their dependencies. :ref:`Symfony Flex <symfony-flex>` is a Composer plugin
50-
designed to automate some of the most common tasks performed in Symfony
51-
applications. Using Flex is optional but recommended because it improves your
52-
productivity significantly.
53-
54-
Use the Directory Structure Proposed by Flex
55-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38+
Use the Default Directory Structure
39+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5640

5741
Unless your project follows a development practice that imposes a certain
58-
directory structure, follow the structure proposed by Symfony Flex. It's flat,
42+
directory structure, follow the default Symfony directory structure. It's flat,
5943
self-explanatory and not coupled to Symfony:
6044

6145
.. code-block:: text
@@ -108,7 +92,7 @@ Use Parameters for Application Configuration
10892

10993
These are the options used to modify the application behavior, such as the sender
11094
of email notifications, or the enabled `feature toggles`_. Their value doesn't
111-
change per machine, so it's not worth it to define them as environment variables.
95+
change per machine, so don't define them as environment variables.
11296

11397
Define these options as :ref:`parameters <configuration-parameters>` in the
11498
``config/services.yaml`` file. You can override these options per
@@ -165,17 +149,14 @@ Business Logic
165149
Don't Create any Bundle to Organize your Application Logic
166150
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167151

168-
When Symfony 2.0 was released, Symfony applications used bundles to divide their
169-
code into logical features: UserBundle, ProductBundle, InvoiceBundle, etc.
152+
When Symfony 2.0 was released, applications used :doc:`bundles </bundles>` to
153+
divide their code into logical features: UserBundle, ProductBundle,
154+
InvoiceBundle, etc. However, a bundle is meant to be something that can be
155+
reused as a stand-alone piece of software.
170156

171-
However, a bundle is meant to be something that can be reused as a stand-alone
172-
piece of software. If UserBundle cannot be used "as is" in other Symfony
173-
applications, then it shouldn't be its own bundle. Moreover, if InvoiceBundle
174-
depends on ProductBundle, then there's no advantage to having two separate bundles.
175-
176-
Symfony applications can still use third-party bundles (installed in ``vendor/``)
177-
to add features, but you should use PHP namespaces instead of bundles to organize
178-
your own code.
157+
If you need to reuse some feature in your projects, create a bundle for it (in a
158+
private repository, to not make it publicly available). For the rest of your
159+
application code, use PHP namespaces to organize code instead of bundles.
179160

180161
Use Autowiring to Automate the Configuration of Application Services
181162
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -204,8 +185,7 @@ most services will be configured automatically. However, in some edge cases
204185
you'll need to configure services (or parts of them) manually.
205186

206187
YAML is the format recommended to configure services because it's friendly to
207-
newcomers and concise, but Symfony also supports XML and PHP configuration, so
208-
you can use whatever format you like.
188+
newcomers and concise, but Symfony also supports XML and PHP configuration.
209189

210190
Use Annotations to Define the Doctrine Entity Mapping
211191
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -240,13 +220,9 @@ Use Annotations to Configure Routing, Caching and Security
240220
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
241221

242222
Using annotations for routing, caching and security simplifies configuration.
243-
You don't need to browse tens of files created with different formats (YAML, XML,
223+
You don't need to browse several files created with different formats (YAML, XML,
244224
PHP): all the configuration is just where you need it and it only uses one format.
245225

246-
The only exception is when the annotations are too complex, such as when using
247-
long expressions in the ``@Security`` annotation or lots of variables and
248-
requirements in the ``@Route`` annotation.
249-
250226
Don't Use Annotations to Configure the Controller Template
251227
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
252228

@@ -278,13 +254,6 @@ the controller (e.g. by calling to a :doc:`Doctrine repository method </doctrine
278254
Templates
279255
---------
280256

281-
Use Twig to Create your Templates
282-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283-
284-
:ref:`Twig <twig-language>` is more concise, readable and safe than PHP. Its
285-
performance is comparable because Symfony compiles Twig templates to PHP and
286-
caches the result.
287-
288257
Use Snake Case for Template Names and Variables
289258
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290259

0 commit comments

Comments
 (0)