Symfony 2 多个应用程序? [英] Symfony 2 multiple apps?

查看:24
本文介绍了Symfony 2 多个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是与 Symfony2 相关的最可怕的话题,因为经过一周的搜索和测试,我仍然无法找到答案.

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.

简而言之,我正在构建一个包含多个子域的应用程序,我希望为所有子域使用不同的配置,同时从/src 共享多个包,更重要的是,导入中央配置和路由(以及每个应用程序自己的)

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)

我开始创建单独的/app 目录、AppKernal.php 文件和引导程序文件.与此有关的主要问题在另一个问题中有详细说明,该问题没有收到任何答案(不是我责怪任何人 TBH :D).Symfony2 多个用于子域路由的配置和路由文件

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

我找到了关于这件事的讨论,Fabian 甚至参与了这个:https://groups.google.com/forum/?fromgroups=#!topic/symfony-devs/yneojUuFiqw

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

关于 github 的 PR 的讨论以在 2.2 版中提供支持(我听说还有 6 个月)https://github.com/symfony/symfony/pull/3378

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?

我几乎处于看起来这根本不可能的阶段.对于一个被吹捧为 Symfony 的系统,我觉得这真的很奇怪,尤其是当 Symfony1.4 看起来很容易做到这一点时.

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.

更新

感谢您的回复.挑战是,有一个配置层次结构.这些配置依次导入自己的 routing.yml 文件.

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

例如:域 http://testing.api.mydomain.com 将包括以下配置:

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

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

全部导入自己的routing.yml文件.但是只加载了 config_api.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.

干杯

推荐答案

通过将代码拆分到多个内核中,可以实现多个应用程序项目.

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

然后您可以受益:

  • 多个网络根(适用于不同的域)
  • 共享&特定配置(通过导入)
  • 明确分离捆绑包...

我在这里描述了整个过程:http://jolicode.com/blog/multiple-applications-with-symfony2,您可以在此处找到示例分发:https://github.com/damienalexandre/symfony-standard

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

这篇关于Symfony 2 多个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆