dongwen5351 2015-03-11 06:46
浏览 113
已采纳

php项目共享公共代码

Thanks in advance for your help...

I come from a Java/Maven development environment and have been extremely familiar with Java dependencies and sharing common code using Maven.

I've recently moved to an organization that is PHP based. We have 3 different projects, all which have a shared code base. Up until now, the dev's have simply copy/pasted code from one project to another to keep the shared code in sync across projects.

Previously in the Java/Maven world, the shared code would be maintained in a separate project, and create a JAR. You would then "mvn install" that module, which would install that JAR in a local repository, and the project that needs that "dependency" would download it from your local repository, allowing for quick development of shared code AND the project using the shared code.

I've been looking for something similar in PHP and haven't been able to find it. I've found suggestions like Git submodules, PHARs and PEARs. But I'm seeing people complain about Git Submodules (https://softwareengineering.stackexchange.com/questions/158847/recommended-methodology-for-working-with-shared-libraries-and-mercurial), and our devs are saying that using PHARs and PEARs incredibly slow down dev efforts because they have to build the shared library before they can use the shared library (not to mention I can't find a accepted standard of "building" PHP).

Another option I've considered is having the shared code live "somewhere" on the file system and referencing the filesystem in code. This is unattractive to me because it makes the environment difficult to set up (imagine if you have a 5 common libraries, you have to check all 5 out just to get your code to work).

So my question is, what are people using to tackle this issue? Also please correct any assumptions I may have made above (re: PEARs, PHARs, PHP Building, etc)!

  • 写回答

1条回答 默认 最新

  • dpik71879 2015-03-11 07:04
    关注

    I think you should definitely look into Composer, sort of Maven for PHP projects.

    Thats solves a lot of package management problems in PHP projects.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度