简体   繁体   English

Symfony2:两个项目之间的共享包

[英]Symfony2 : Share Bundles between 2 projects

Our company decided to move to Symfony2 and now we are trying to re-write our application. 我们公司决定迁移到Symfony2,现在我们正在尝试重新编写我们的应用程序。 I'm still new to Symfony2 and trying to figure out what is the best way to build the app. 我还是Symfony2的新手,并试图找出什么是构建应用程序的最佳方法。

our app consists of 2 part each part is on a different server: 我们的应用程序由两部分组成,每个部分位于不同的服务器上:

  • A contains all the logic required to get/store/update records in database A包含获取/存储/更新数据库中的记录所需的所有逻辑
  • B users requests go to, process the request and send another request to A for any database interaction B个用户的请求转到,处理该请求,并将另一个请求发送给A以进行任何数据库交互

I'm planning to use Doctrine in A so i created all the required Entities, but i feel i need to share A entities with B since it's easier to create/validate forms using entities. 我打算在A中使用Doctrine,所以我创建了所有必需的实体,但是我觉得我需要与B共享A实体,因为使用实体创建/验证表单更容易。

  • Am I going into the right direction or I don't have to share the entities? 我是朝着正确的方向走,还是不必共享实体?
  • If I share the entities and B doesn't have any database connection, will that create any problem for me? 如果我共享实体,而B没有任何数据库连接,那会给我带来任何问题吗?
  • If I'm going to do this approach (separate logic and database calls into 2 separate bundles each one on a different server) is there any consequences? 如果我要采用这种方法(将逻辑和数据库调用分成2个单独的捆绑,每个捆绑在不同的服务器上),会不会有后果? where should i build Services ? 我应该在哪里建立服务? on A or B or also i would have to share Services too? AB上,还是我也必须共享服务?

Thanks 谢谢

I did not have the exact problem you described, but I wanted to share/extend some entities between applications in single project. 我没有您描述的确切问题,但是我想在单个项目中的应用程序之间共享/扩展某些实体。 However, I was recommended by good folks on SO to branch entire project. 但是,SO方面的好人推荐我来分支整个项目。

I suppose you will be using Git so you'll have two branches : A and B. Both will have common files (entities in you case), but will certainly contain different controllers/services as necessary. 我想您将使用Git,所以您将拥有两个分支 :A和B。这两个分支都将具有公用文件(在您的情况下为实体),但是必定会包含必要的不同控制器/服务。

Now, since you've mentioned two servers, not only you will have separated code but you will be able to set different deployment scripts both for A and B. 现在,由于您提到了两台服务器,因此不仅将有单独的代码,而且将能够为A和B设置不同的部署脚本。

The downside: I believe that some intermediate knowledge of git branching will be necessary. 缺点:我认为有必要掌握git分支的一些中级知识。

Is that acceptable for you? 你可以接受吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM