Symfony2: Folder Structure

This entry describes the Symfony2 directory structure; providing a broad understanding of how a project is structured, and laying the ground for file system level security and customization.

Below are diagrams for each main folder, along with a description of its components (based on:

app/ folder:

AppKernel.php – Main configuration entry point. Provides registerContainerConfiguration and registerBundles.

AppCache.php – Caching kernel, wrapper of AppKernel.php.

autoload.php – Enables extending standard auto-loading functionality.

check.php – Checks Symfony2 requirements.

console – Facilitates creations and use of command line scripts.

phpunit.xml.dist – Main phpunit configuration file.

Resources/ – Base views folder.

config/ – Hosts configuration files for: routing, security, application and parameters.

logs/ – Hosts application log files.

cache/ – Hosts cached items.

SymfonyRequirements.php – Project requirements file.

src/ folder:

[Vendor]/ – project’s vendor name (e.g.: Acme)

[Vendor]/[Project]Bundle/ – project specific bundle name (e.g.: DemoBundle)

[Vendor]/[Project]Bundle/Controller/ – controllers

[Vendor]/[Project]Bundle/Resources/ – resource files

[Vendor]/[Project]Bundle/Resources/config/ – project specific configuration (routing and services)

[Vendor]/[Project]Bundle/Resources/views/ – twig view files

[Vendor]/[Project]Bundle/Resources/public/ – css, image and javascript files

[Vendor]/[Project]Bundle/Tests/ – unit tests folder

[Vendor]/[Project]Bundle/Twig/ – Twig extensions

[Vendor]/[Project]Bundle/Form/ – form definition folder

[Vendor]/[Project]Bundle/EventListener/ – HttpKernel event listeners

[Vendor]/[Project]Bundle/DependencyInjection/ – dependency definition files

[Vendor]/[Project]Bundle/[Vendor][Project]Bundle.php – main bundle namespace and class

vendor/ folder:

composer/ – composer dependencies manager

doctrine/ – doctrine2 ORM

incenteev/ – tool for “managing your ignored parameters with Composer”

jdorn/ – a “class for formatting sql statements”

kriswallsmith/ – assetic library

monolog/ – logging library

psr/ – PSR-3 related classes, interfaces and traits

sensio/ – tools for configuring controllers with annotations

swiftmailer/ – mailing library

symfony/ – main framework libraries

twig/ – twig templating engine

web/ folder:

app.php – production front controller

app_dev.php – development front controller

config.php – configuration script

bundles/ – bundle specific public content

[name]/ – project specific public content

bin/ folder:

doctrine.php – doctrine command line interface

doctrine – alias for doctrine.php

NOTE: This page provides a brief description of folders hosted within a Symfony2 distribution package, installed via Composer.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.