如何集成两个位于不同服务器上的Symfony项目?

huangapple go评论48阅读模式
英文:

How to integrate two Symfony projects that are on different servers?

问题

I have two symfony projects and that share the same database servers.

我有两个Symfony项目,它们共享相同的数据库服务器。

I would like to, if possible, from one project call some Entity/Repository of another. The problem is:

如果可能的话,我想从一个项目中调用另一个项目的某些实体/存储库。问题是:

Both project are in different servers.

这两个项目位于不同的服务器上。

So, is there some way to, maybe using services, make the projects talk to each other?

所以,是否有一种方法,也许可以使用服务来让这两个项目相互通信?

I tried to create a service passing SERVER IP + folder directory but it returns an error like:

我尝试创建一个服务,传递服务器IP + 文件夹目录,但它返回了一个错误,类似于:

what i did:

我做了什么:

Ia\:
    resource: "ftp://172.21.0.6/src/"

what returns:

返回的内容:

Warning: file_exists(): connect() failed: Connection refused in

警告:file_exists():连接失败:连接被拒绝

英文:

I have two symfony projects and that share the same database servers.

I would like to, if possible, from one project call some Entity/Repository of another. The problem is:

Both project are in different servers.

So, is there some way to, maybe using services, make the projects talk to each other?

I tried to create a service passing SERVER IP + folder directory but it returns an error like:

what i did:

Ia\:
    resource: "ftp://172.21.0.6/src/"

what returns:

Warning: file_exists(): connect() failed: Connection refused in

答案1

得分: 2

短答:不行。你不能使用另一个托管在另一个主机上的项目的PHP类。

你可以做的是:

  • 使用HTTP通信:在项目A中公开功能作为API端点,然后从项目B中调用这些端点。
  • 引入你自己的库:将通用功能提取到第三个项目中,即一个库,你可以在两个项目中安装它(使用Composer)。
英文:

Short anwser: no. You cannot use php classes of another project hosted on another host.

What you could do:

  • Talk http: Expose functionality of project A in api endpoints and call those endpoints from project B.
  • Introduce your own library: Factor out common functionality into a third project, namely a library that you install in both projects (using composer).

huangapple
  • 本文由 发表于 2023年2月9日 03:36:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390899.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定