Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2 multiple apps?

Tags:

symfony

This appears to be the scariest topic relating to Symfony2, as after a week of searching and testing, I am still unable to find an answer to this.

In short, I am building an application that will have several subdomains, and I would like a different configuraton for all of them, while sharing multiple bundles from /src, and more importantly, import central config and routes (As well as each app's own)

I went down the road of creating individual /app directories, AppKernal.php files and bootstrap files. The main issue with this is detailed in another question, which has recieved no answers (not that I blame anyone TBH :D). Symfony2 multiple config and routing files for subdomain routing

I have found discussion on the matter, Fabian even takes part in this: https://groups.google.com/forum/?fromgroups=#!topic/symfony-devs/yneojUuFiqw

And this discussion on a PR to github to provide support in version 2.2 (still 6mo away I hear) https://github.com/symfony/symfony/pull/3378

Is there anyone out there who has done this before? Is the process easy enough to explain? Is there any information available to assist with this?

I'm pretty much at the stage where it appears this simply is not possible. Which I find really strange for a system as touted as Symfony, especially when it appears Symfony1.4 did this rather easily.

Update

Thanks for your responses. The challenge is, there is a hierarchy of configs. These configs in turn import their own routing.yml files.

For instance: the domain http://testing.api.mydomain.com would include the following configs:

config_api.yml -> config_testing.yml -> config_dev.yml -> config.yml

All import their own routing.yml file. But only the one in config_api.yml is loaded. It seems framework: router: config option overrides previous usages in other config files, rather than extends.

In all fairness, the location of the app code is inconsequential. Having a hierarchical configuration with hierarchical routes seems to be the gotacha.

Cheers

like image 514
Aaryn Avatar asked Oct 01 '12 03:10

Aaryn


1 Answers

Multiple applications projects can be achieved by splitting your code in multiple Kernels.

You can then benefit:

  • multiple web roots (useful for differents domains)
  • shared & specific config (via imports)
  • clean separation of Bundles...

I have described the whole process here: http://jolicode.com/blog/multiple-applications-with-symfony2 and you can find an example distribution here: https://github.com/damienalexandre/symfony-standard

like image 119
Damien Avatar answered Dec 04 '22 15:12

Damien