Skip to content

Commit 8236647

Browse files
committed
feature #5916 [3.0][Best Practices][Quick Tour] Use the 3.0 directory structure (WouterJ)
This PR was merged into the master branch. Discussion ---------- [3.0][Best Practices][Quick Tour] Use the 3.0 directory structure | Q | A | --- | --- | Doc fix? | yes | New docs? | yes | Applies to | 3.0+ | Fixed tickets | part of #5898 Commits ------- c6d436b [QuickTour] Use new directory structure 215c36d [BestPractices] Use new directory structure
2 parents dbf0d31 + c6d436b commit 8236647

File tree

5 files changed

+41
-48
lines changed

5 files changed

+41
-48
lines changed

best_practices/business-logic.rst

Lines changed: 5 additions & 1 deletion
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

Lines changed: 22 additions & 35 deletions
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

quick_tour/the_architecture.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ but the recommended structure is as follows:
1515

1616
``app/``
1717
The application configuration, templates and translations.
18+
``bin/``
19+
Executable files (e.g. ``bin/console``).
1820
``src/``
1921
The project's PHP code.
22+
``tests/``
23+
Automatic tests (e.g. Unit tests).
24+
``var/``
25+
Generated files (cache, logs, etc.).
2026
``vendor/``
2127
The third-party dependencies.
2228
``web/``
@@ -30,7 +36,7 @@ stylesheets and JavaScript files. It is also where each :term:`front controller`
3036
lives, such as the production controller shown here::
3137

3238
// web/app.php
33-
require_once __DIR__.'/../app/bootstrap.php.cache';
39+
require_once __DIR__.'/../var/bootstrap.php.cache';
3440
require_once __DIR__.'/../app/AppKernel.php';
3541

3642
use Symfony\Component\HttpFoundation\Request;
@@ -260,7 +266,7 @@ Symfony applications can contain several configuration files defined in
260266
several formats (YAML, XML, PHP, etc.) Instead of parsing and combining
261267
all those files for each request, Symfony uses its own cache system. In
262268
fact, the application configuration is only parsed for the very first request
263-
and then compiled down to plain PHP code stored in the ``app/cache/``
269+
and then compiled down to plain PHP code stored in the ``var/cache/``
264270
directory.
265271

266272
In the development environment, Symfony is smart enough to update the cache
@@ -271,10 +277,10 @@ the ``prod`` environment:
271277

272278
.. code-block:: bash
273279
274-
$ php app/console cache:clear --env=prod
280+
$ php bin/console cache:clear --env=prod
275281
276282
When developing a web application, things can go wrong in many ways. The
277-
log files in the ``app/logs/`` directory tell you everything about the requests
283+
log files in the ``var/logs/`` directory tell you everything about the requests
278284
and help you fix the problem quickly.
279285

280286
Using the Command Line Interface
@@ -288,13 +294,13 @@ Run it without any arguments to learn more about its capabilities:
288294

289295
.. code-block:: bash
290296
291-
$ php app/console
297+
$ php bin/console
292298
293299
The ``--help`` option helps you discover the usage of a command:
294300

295301
.. code-block:: bash
296302
297-
$ php app/console debug:router --help
303+
$ php bin/console debug:router --help
298304
299305
Final Thoughts
300306
--------------

0 commit comments

Comments
 (0)