Symfony 2 multiple apps?

后端 未结 6 1546
灰色年华
灰色年华 2021-01-31 12:06

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 buildin

6条回答
  •  孤街浪徒
    2021-01-31 12:58

    Sorry for necroing...

    I just want to say that I have looked into multiple application structure for Symfony2 as well. Since version 2.4, when routing supported hostname based routing, there has been no need for multiple apps.

    All you now need to do is separate your "apps" into different bundles, say AcmeSiteBundle and AcmeApiBundle, then in app/config/routing.yml:

    acme_site:
        host:     "www.{domain}"
        resource: "@AcmeSiteBundle/Resources/config/routing.yml"
        prefix:   /
        defaults:
            domain: "%domain%"
        requirements:
            domain: "%domain%"
    
    acme_api:
        host:     "api.{domain}"
        resource: "@AcmeApiBundle/Resources/config/routing.yml"
        prefix:   /
        defaults:
            domain: "%domain%"
        requirements:
            domain: "%domain%"
    

    Remember to have domain parameter set in app/config/parameters.yml

    parameters:
        .....
        domain: example.com
    

提交回复
热议问题