PHP中替换某个包或某个类

在使用composer组件时,有时候需要对包进行一些自定义修改,有一些教程中写需要修改composer.json,然后发布到Packagist,但如果只是适应自己需求所作的小修改,其实并没有必要发布到Packagist,而这样做也是Packagist不推荐的:

Do not submit forks of existing packages. If you need to test changes to a package that you forked to patch, use VCS Repositories instead. If however it is a real long-term fork you intend on maintaining feel free to submit it.

如果只是适应自己的小修改,fork项目回来后,直接对需要修改的位置进行修改并提交,然后在composer.json加上repositories,并指定fork回来的仓库的地址。

复制代码
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/xxx/database"
    },
]

安装后看到composer输出(这里用hyperf/database做例子)

复制代码
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Removing hyperf/database (v2.2.41)
  - Installing hyperf/database (v2.2.41): Cloning xxxxxxxxx

Reference

如何利用 composer 替换第三方包里的某个类(color-thief-php为例) - 灰信网(软件开发博客聚合)

在Composer中使用自己修改的包 - DevsDawn

相关推荐
helloworldandy14 分钟前
高性能图像处理库
开发语言·c++·算法
2401_8365631816 分钟前
C++中的枚举类高级用法
开发语言·c++·算法
chao18984427 分钟前
矢量拟合算法在网络参数有理式拟合中的应用
开发语言·算法
EmbedLinX44 分钟前
C++ 面向对象
开发语言·c++
weixin_445402301 小时前
C++中的命令模式变体
开发语言·c++·算法
Hgfdsaqwr1 小时前
实时控制系统优化
开发语言·c++·算法
2301_821369611 小时前
嵌入式实时C++编程
开发语言·c++·算法
sjjhd6521 小时前
多核并行计算优化
开发语言·c++·算法
一起养小猫2 小时前
Flutter for OpenHarmony 实战 表单处理与验证完整指南
android·开发语言·前端·javascript·flutter·harmonyos
leiming62 小时前
FreeRTOS 的任务与 Linux
java·开发语言