如何以正确的方式(在PHP中)编辑由作曲家加载的供应商代码? [英] How to edit composer-loaded vendor code the right way (in PHP)?

查看:64
本文介绍了如何以正确的方式(在PHP中)编辑由作曲家加载的供应商代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,作曲家加载的依赖项有错误或缺少您需要的东西。

Sometimes composer-loaded dependencies are buggy or are missing something you need.

1。)通常是否可以触摸/编辑作曲家加载的任何内容?

1.) Is it in general allowed to touch/edit anything that composer loaded ?

2。)如果是,那么如何防止这些编辑被覆盖/生成与下一次更新冲突

2.) If yes, then how to prevent these edit from being overwritten / generating conflicts with the next update

3。)如果否,那么需要编辑作曲家加载的依赖项时该怎么做?

3.) If no, then what the way-to-go when edits of composer-loaded dependencies are needed ?

推荐答案


  1. 简单的答案是否。

  1. The simple answer is no.

您可以编辑文件,但更改不是永久的。

You can edit the files, but the changes are not permanent.

您必须找到一种方法来修复该错误。可用的方法有:

You have to find a way to get the bug fixed. Available methods are:


  1. 向上游报告错误,可能有建议的修复(补丁或请求请求),并等待其被包含在新版本中

  2. 克隆原始软件,修复那里的错误,并在期间使用 composer.json 指向克隆的存储库a)发生的时间。为了满足所有依赖关系,您可能必须将dev-master分支(或用于修复该错误的任何分支)作为下一个版本的别名。

  3. 如果未维护原始项目,则可以考虑考虑使用新名称重新发布它,并修复该错误,并在 composer.json 中声明该新软件替代了旧软件。有关详细信息,请参见我的回答

  4. 您还可以切换到错误较少的其他软件。

  5. 您还可以尝试通过在自己的代码库中扩展错误类来修补该错误,或​​者

  1. report the bug upstream, possibly with a suggested fix (patch or pull request), and wait for it to be included in a new version
  2. clone the original software, fix the bug there, and point to your cloned repository with your composer.json during the time for a) to happen. You might have to alias the dev-master branch (or whatever branch you used to fix the bug) as the next version to satisfy all dependencies.
  3. If the original project is unmaintained, you can think about re-publishing it under a new name, with the bug fixed, and stating in the composer.json that this new software replaces the old one. Please see my answer here for details.
  4. You could also switch to a different software that has less bugs.
  5. You could also try to patch the bug by extending the buggy class in your own codebase, or work around it in other means.


这篇关于如何以正确的方式(在PHP中)编辑由作曲家加载的供应商代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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