Skip to content

Commit

Permalink
[BestPractices] Use new directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Nov 28, 2015
1 parent af97ce1 commit 215c36d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
6 changes: 5 additions & 1 deletion best_practices/business-logic.rst
Expand Up @@ -21,6 +21,8 @@ Inside here, you can create whatever directories you want to organize things:
│ └─ AppBundle/
│ └─ Utils/
│ └─ MyClass.php
├─ tests/
├─ var/
├─ vendor/
└─ web/
Expand All @@ -40,6 +42,8 @@ and put things there:
│ │ └─ Utils/
│ │ └─ MyClass.php
│ └─ AppBundle/
├─ tests/
├─ var/
├─ vendor/
└─ web/
Expand Down Expand Up @@ -318,7 +322,7 @@ command:

.. code-block:: bash
$ php app/console doctrine:fixtures:load
$ php bin/console doctrine:fixtures:load
Careful, database will be purged. Do you want to continue Y/N ? Y
> purging database
Expand Down
57 changes: 22 additions & 35 deletions best_practices/creating-the-project.rst
Expand Up @@ -27,14 +27,9 @@ to create files and execute the following commands:

.. code-block:: bash
# Linux, Mac OS X
$ cd projects/
$ symfony new blog
# Windows
c:\> cd projects/
c:\projects\> php symfony.phar new blog
This command creates a new directory called ``blog`` that contains a fresh new
project based on the most recent stable Symfony version available. In addition,
the installer checks if your system meets the technical requirements to execute
Expand All @@ -58,27 +53,35 @@ number of files and directories generated automatically:
blog/
├─ app/
│ ├─ console
│ ├─ cache/
│ ├─ config/
│ ├─ logs/
│ └─ Resources/
├─ bin
│ └─ console
├─ src/
│ └─ AppBundle/
├─ var/
│ ├─ cache/
│ ├─ logs/
│ └─ sessions/
├─ tests/
│ └─ AppBundle/
├─ vendor/
└─ web/
This file and directory hierarchy is the convention proposed by Symfony to
structure your applications. The recommended purpose of each directory is the
following:

* ``app/cache/``, stores all the cache files generated by the application;
* ``app/config/``, stores all the configuration defined for any environment;
* ``app/logs/``, stores all the log files generated by the application;
* ``app/Resources/``, stores all the templates and the translation files for the
application;
* ``src/AppBundle/``, stores the Symfony specific code (controllers and routes),
your domain code (e.g. Doctrine classes) and all your business logic;
* ``var/cache/``, stores all the cache files generated by the application;
* ``var/logs/``, stores all the log files generated by the application;
* ``var/sessions/``, stores all the session files generated by the application;
* ``tests/AppBundle/``, stores the automatic tests (e.g. Unit tests) of the
application.
* ``vendor/``, this is the directory where Composer installs the application's
dependencies and you should never modify any of its contents;
* ``web/``, stores all the front controller files and all the web assets, such
Expand Down Expand Up @@ -123,13 +126,18 @@ that follows these best practices:
blog/
├─ app/
│ ├─ console
│ ├─ cache/
│ ├─ config/
│ ├─ logs/
│ └─ Resources/
├─ bin/
│ └─ console
├─ src/
│ └─ AppBundle/
├─ tests/
│ └─ AppBundle/
├─ var/
│ ├─ cache/
│ ├─ logs/
└─ sessions/
├─ vendor/
└─ web/
├─ app.php
Expand All @@ -142,7 +150,7 @@ that follows these best practices:

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

In addition, Symfony3 will use a slightly different directory structure when
it's released:

.. code-block:: text
blog-symfony3/
├─ app/
│ ├─ config/
│ └─ Resources/
├─ bin/
│ └─ console
├─ src/
├─ var/
│ ├─ cache/
│ └─ logs/
├─ vendor/
└─ web/
The changes are pretty superficial, but for now, we recommend that you use
the Symfony directory structure.

.. _`Composer`: https://getcomposer.org/
.. _`Get Started`: https://getcomposer.org/doc/00-intro.md
.. _`Composer download page`: https://getcomposer.org/download/
Expand Down
4 changes: 0 additions & 4 deletions best_practices/introduction.rst
Expand Up @@ -76,12 +76,8 @@ installer and then execute this command to download the demo application:

.. code-block:: bash
# Linux and Mac OS X
$ symfony demo
# Windows
c:\> php symfony demo
**The demo application is a simple blog engine**, because that will allow us to
focus on the Symfony concepts and features without getting buried in difficult
implementation details. Instead of developing the application step by step in
Expand Down
4 changes: 2 additions & 2 deletions best_practices/tests.rst
Expand Up @@ -30,8 +30,8 @@ A functional test can be as easy as this:

.. code-block:: php
// src/AppBundle/Tests/ApplicationAvailabilityFunctionalTest.php
namespace AppBundle\Tests;
// tests/AppBundle/ApplicationAvailabilityFunctionalTest.php
namespace Tests\AppBundle;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
Expand Down

0 comments on commit 215c36d

Please sign in to comment.