0

I'm still learning my way around Symfony2 and wondered if anyone could explain the logic behind the changes to the directory structure in Symfony3? It would be interesting to hear the justification for the changes and would hopefully give some clarify on the 'magic' of inheritance/overwriting classes.

Below are the standard directory structures for both versions of Symfony:

Symfony 2:

blog/
├─ app/
│ ├─ console
│ ├─ cache/
│ ├─ config/
│ ├─ logs/
│ └─ Resources/
├─ src/
│ └─ AppBundle/
├─ vendor/
└─ web/

Symfony 3:

blog-symfony3/
├─ app/
│ ├─ config/
│ └─ Resources/
├─ bin/
│ └─ console
├─ src/
├─ var/
│ ├─ cache/
│ └─ logs/
├─ vendor/
└─ web/
Bendy
  • 3,506
  • 6
  • 40
  • 71
  • 5
    This question has an excellent answer outlining the differences and their benefits: http://stackoverflow.com/questions/23993295/what-is-the-new-symfony-3-directory-structure – Kaivosukeltaja Nov 20 '15 at 13:02
  • 1
    I'd guess the justification is that logs, console and cache aren't something that you create or change by hand, so they don't belong mixed into your app folder. Cache and log files would be expected to grow over time, so var makes sense. I'm not exactly sure what console contains, but I'd bet it's binary data, so bin would make sense. – Parris Varney Nov 20 '15 at 14:08

1 Answers1

2

As commented, this has already been outlined in my answer here.

A google search for symfony 3 directory structure also returns it as the first result (at the time of writing).


Here is a quick summary:

  1. The cache, logs and bootstrap.php.cache have been moved to the /var directory in the root of the project. This makes it easier to handle permissions, you should make the entire var directory writable. (similar to a unix like OS). You could also write your own application specific files here.

  2. All binary executables (console, symfony_requirements, doctrine) are all now located within the bin directory (similar to a unix like OS), you can also add your own executables here.
    Tip: Update your PATH environment variable with the following to automatically include all files in the bin directory (in the current working directory) in your path. PATH="./bin:$PATH"

  3. phpunit can now be run from the project root without specifying the configuration file via the -c switch.
    <3.0 - phpunit -c app/phpunit.xml
    >3.0 - phpunit


You can read a more detailed answer here:

What is the new Symfony 3 directory structure?

Community
  • 1
  • 1
Anil
  • 21,730
  • 9
  • 73
  • 100
  • Thanks for answering Anil - I'd followed the link to your answer from @Kaivosukeltaja comment...no further questions! – Bendy Dec 02 '15 at 20:48