Search code examples
symfonysymfony-2.5

Where to place Application bundles?


I have an application written with Symfony and want to merge some small bundles as part of that app.

Regarding the quick Symfony2 bundle tour from Sonata, I need an ApplicationBundle.

quick Symfony2 bundle tour:

  • There are two types of bundles:
    • Application Bundle (AB),
    • Vendor Bundle (VB), that should not be modified inside a project.
  • The AB directory is where developers implement the project requirements,
  • An AB can overwrite almost everything from a VB, example: you can redefine a VB template at the AB level.

(Source)

Symfony documentation says about architecture:

The directory structure of a Symfony application is rather flexible, but the recommended structure is as follows:

  • app/: the application configuration;
  • src/: the project's PHP code;
  • vendor/: the third-party dependencies;
  • web/: the web root directory

(Source)

But where shall I place it?

There are two possibilities:

  • app/Application (Sonata EasyExtends places ApplicationBundles here)
  • src

But what is the right one?
And why are there two possibilities?

The Symfony documentation doesn't cover ApplicationBundle.

Thanks for any hints.


Solution

  • The documentation say that :

    • Application Bundles (in 2 words, this is important) are stored in src/ directory.
    • Vendor Bundles are stored in vendor/directory (and came from your composer.json dependencies).

    You can (and should) create many bundles for you application.