Skip to content

Commit 215c36d

Browse files
committed
[BestPractices] Use new directory structure
1 parent af97ce1 commit 215c36d

File tree

4 files changed

+29
-42
lines changed

4 files changed

+29
-42
lines changed

best_practices/business-logic.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Inside here, you can create whatever directories you want to organize things:
2121
│ └─ AppBundle/
2222
│ └─ Utils/
2323
│ └─ MyClass.php
24+
├─ tests/
25+
├─ var/
2426
├─ vendor/
2527
└─ web/
2628
@@ -40,6 +42,8 @@ and put things there:
4042
│ │ └─ Utils/
4143
│ │ └─ MyClass.php
4244
│ └─ AppBundle/
45+
├─ tests/
46+
├─ var/
4347
├─ vendor/
4448
└─ web/
4549
@@ -318,7 +322,7 @@ command:
318322

319323
.. code-block:: bash
320324
321-
$ php app/console doctrine:fixtures:load
325+
$ php bin/console doctrine:fixtures:load
322326
323327
Careful, database will be purged. Do you want to continue Y/N ? Y
324328
> purging database

best_practices/creating-the-project.rst

+22-35
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ to create files and execute the following commands:
2727

2828
.. code-block:: bash
2929
30-
# Linux, Mac OS X
3130
$ cd projects/
3231
$ symfony new blog
3332
34-
# Windows
35-
c:\> cd projects/
36-
c:\projects\> php symfony.phar new blog
37-
3833
This command creates a new directory called ``blog`` that contains a fresh new
3934
project based on the most recent stable Symfony version available. In addition,
4035
the installer checks if your system meets the technical requirements to execute
@@ -58,27 +53,35 @@ number of files and directories generated automatically:
5853
5954
blog/
6055
├─ app/
61-
│ ├─ console
62-
│ ├─ cache/
6356
│ ├─ config/
64-
│ ├─ logs/
6557
│ └─ Resources/
58+
├─ bin
59+
│ └─ console
6660
├─ src/
6761
│ └─ AppBundle/
62+
├─ var/
63+
│ ├─ cache/
64+
│ ├─ logs/
65+
│ └─ sessions/
66+
├─ tests/
67+
│ └─ AppBundle/
6868
├─ vendor/
6969
└─ web/
7070
7171
This file and directory hierarchy is the convention proposed by Symfony to
7272
structure your applications. The recommended purpose of each directory is the
7373
following:
7474

75-
* ``app/cache/``, stores all the cache files generated by the application;
7675
* ``app/config/``, stores all the configuration defined for any environment;
77-
* ``app/logs/``, stores all the log files generated by the application;
7876
* ``app/Resources/``, stores all the templates and the translation files for the
7977
application;
8078
* ``src/AppBundle/``, stores the Symfony specific code (controllers and routes),
8179
your domain code (e.g. Doctrine classes) and all your business logic;
80+
* ``var/cache/``, stores all the cache files generated by the application;
81+
* ``var/logs/``, stores all the log files generated by the application;
82+
* ``var/sessions/``, stores all the session files generated by the application;
83+
* ``tests/AppBundle/``, stores the automatic tests (e.g. Unit tests) of the
84+
application.
8285
* ``vendor/``, this is the directory where Composer installs the application's
8386
dependencies and you should never modify any of its contents;
8487
* ``web/``, stores all the front controller files and all the web assets, such
@@ -123,13 +126,18 @@ that follows these best practices:
123126
124127
blog/
125128
├─ app/
126-
│ ├─ console
127-
│ ├─ cache/
128129
│ ├─ config/
129-
│ ├─ logs/
130130
│ └─ Resources/
131+
├─ bin/
132+
│ └─ console
131133
├─ src/
132134
│ └─ AppBundle/
135+
├─ tests/
136+
│ └─ AppBundle/
137+
├─ var/
138+
│ ├─ cache/
139+
│ ├─ logs/
140+
└─ sessions/
133141
├─ vendor/
134142
└─ web/
135143
├─ app.php
@@ -142,7 +150,7 @@ that follows these best practices:
142150

143151
.. code-block:: bash
144152
145-
$ php app/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction
153+
$ php bin/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction
146154
147155
Extending the Directory Structure
148156
---------------------------------
@@ -152,27 +160,6 @@ structure of Symfony, you can
152160
:doc:`override the location of the main directories </cookbook/configuration/override_dir_structure>`:
153161
``cache/``, ``logs/`` and ``web/``.
154162

155-
In addition, Symfony3 will use a slightly different directory structure when
156-
it's released:
157-
158-
.. code-block:: text
159-
160-
blog-symfony3/
161-
├─ app/
162-
│ ├─ config/
163-
│ └─ Resources/
164-
├─ bin/
165-
│ └─ console
166-
├─ src/
167-
├─ var/
168-
│ ├─ cache/
169-
│ └─ logs/
170-
├─ vendor/
171-
└─ web/
172-
173-
The changes are pretty superficial, but for now, we recommend that you use
174-
the Symfony directory structure.
175-
176163
.. _`Composer`: https://getcomposer.org/
177164
.. _`Get Started`: https://getcomposer.org/doc/00-intro.md
178165
.. _`Composer download page`: https://getcomposer.org/download/

best_practices/introduction.rst

-4
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ installer and then execute this command to download the demo application:
7676

7777
.. code-block:: bash
7878
79-
# Linux and Mac OS X
8079
$ symfony demo
8180
82-
# Windows
83-
c:\> php symfony demo
84-
8581
**The demo application is a simple blog engine**, because that will allow us to
8682
focus on the Symfony concepts and features without getting buried in difficult
8783
implementation details. Instead of developing the application step by step in

best_practices/tests.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ A functional test can be as easy as this:
3030

3131
.. code-block:: php
3232
33-
// src/AppBundle/Tests/ApplicationAvailabilityFunctionalTest.php
34-
namespace AppBundle\Tests;
33+
// tests/AppBundle/ApplicationAvailabilityFunctionalTest.php
34+
namespace Tests\AppBundle;
3535
3636
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
3737

0 commit comments

Comments
 (0)