Gabriel Santos
Gabriel Santos

Reputation: 4974

How to change Symfony2 default structure?

May I change the default Symfony2 structure to fit my needs? I like the follow structure, but don't know how to get it to working..

core/ <- Symfony2 core files
app/ <- All applications
app/Acme/ <- Application for Acme enterprise (with all bundles..)
app/clientone.com/ <- Application for Client One enterprise (with all bundles..)

Upvotes: 1

Views: 2561

Answers (1)

Luke 10X
Luke 10X

Reputation: 1410

Inside symfony2 distribution there are 4 main directories:

  • app (there are customisations to your app)
  • vendors (symfony and other libraries)
  • src (your source code which may or may not to be application specific, there could be bundle ClientoneBundle which is specific to only this application, but also could be a bundle reused among your applications,- such as UserBundle)
  • web (http document root)

So if you have several applications you could keep vendors separately. And each of your application may contain three directories like: - apps/acme/app - apps/acme/src - apps/acme/web - apps/clientone/app - apps/clientone/src - apps/clientone/web - some/where/else/in/filesystem/vendor

To implement such setup is very easy,- all you have to do is edit your autoload.php (which resides in app dir), just replace everywhere __DIR__.'/../vendor to __DIR__.'/../vendor, in other words, tell symfony2 that you moved vendors somewhere else.

(I just renamed app directory in your setup to apps - to be not confused with app directory, inside each of your application)

Upvotes: 3

Related Questions