Symfony 2 is a PHP framework. When you download it, if noticed, Symfony 2 has a directory structure. By default there are 5 directories like app, bin, src,vendor, web. If you had developed any kind of application with Symfony 2 then you might have followed something like put your source code in src, put all static assets in web, write config files in app etc. Again this directory structure is configurable, that means you can customize it according to your project needs. Even though the directory names are self-explanatory, let’s have a deeper look of this structure.
By default Symfony consists of following directories,
- app/: The application configuration
- src/: The project’s PHP code
- vendor/: The third-party dependencies
- web/: The web root directory
app/
‘app’ directory in Symfony 2 holds the application configuration. You can find all configuration related stuff in ‘app/config’ folder. If you need to configure your database or Swiftmailer then you will need to change parameters/settings from here. Apart from that this directory holds the ‘cache’. While writing code in Symfony 2 you will be working with lots of files ranging from xml, yml to php, twig, html etc. Controllers will be written in some file, routes will be defined in some another files, views will be written in some other file and so on. So while serving request Symfony has to read all these necessary files. Since the count of files is too high, to achieve great performance Symfony 2 has inbuilt caching. And this cached data will be stored in ‘cache’ directory. Again there is a ‘log’ directory which has debugging related data, especially useful in development.
Continue reading Understanding Directory Structure of Symfony 2 →