dongxu6418 2011-07-31 17:32
浏览 45
已采纳

在项目中共享自定义PHP代码的最佳方式

I'm developing a distributed environment, mostly in PHP. A lot of the projects that I have share some of the same code. For example my logging code (based on log4php but with some custom additions).

I can just copy-paste this code in every project, but naturally, if I change anything in it I need to re-paste it everywhere and 'hope' it doesn't change anything. Obviously not a good way.

Now, I was wondering: what is the best and simplest way of sharing this code? I'm hoping there is something as easy as making your own private PEAR-like channel? Do people do this for this use case? Or is there an ever easier way? I rather not start with inter-dependent repositories etc. If it matters though, I use Mercurial for versioning.

Thanks all.

  • 写回答

3条回答 默认 最新

  • douduikai0562 2011-07-31 17:42
    关注

    Perhaps the best way (I am using too) is to host the common code in a versioning system such as Git or Mercurial or SVN and checkout this code in each related project. As long such a project does not have updates you can continue to work on your common code. In the case you want to touch a project again that utilizes the common code, you need to perform a source code update or pull. Then you update your project sources according to the changes of the common source base.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建