@@ -32,30 +32,14 @@ to create new Symfony applications:
32
32
$ symfony new my_project_name
33
33
34
34
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.
36
37
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
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
40
57
41
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,
59
43
self-explanatory and not coupled to Symfony:
60
44
61
45
.. code-block :: text
@@ -108,7 +92,7 @@ Use Parameters for Application Configuration
108
92
109
93
These are the options used to modify the application behavior, such as the sender
110
94
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.
112
96
113
97
Define these options as :ref: `parameters <configuration-parameters >` in the
114
98
``config/services.yaml `` file. You can override these options per
@@ -165,17 +149,14 @@ Business Logic
165
149
Don't Create any Bundle to Organize your Application Logic
166
150
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167
151
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.
170
156
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.
179
160
180
161
Use Autowiring to Automate the Configuration of Application Services
181
162
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -204,8 +185,7 @@ most services will be configured automatically. However, in some edge cases
204
185
you'll need to configure services (or parts of them) manually.
205
186
206
187
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.
209
189
210
190
Use Annotations to Define the Doctrine Entity Mapping
211
191
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -240,13 +220,9 @@ Use Annotations to Configure Routing, Caching and Security
240
220
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
241
221
242
222
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,
244
224
PHP): all the configuration is just where you need it and it only uses one format.
245
225
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
-
250
226
Don't Use Annotations to Configure the Controller Template
251
227
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
252
228
@@ -278,13 +254,6 @@ the controller (e.g. by calling to a :doc:`Doctrine repository method </doctrine
278
254
Templates
279
255
---------
280
256
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
-
288
257
Use Snake Case for Template Names and Variables
289
258
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290
259
0 commit comments