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

相关推荐
狂奔的sherry21 小时前
C++ 模板与泛型编程 理解
开发语言·c++
u***u68521 小时前
Java虚拟机内存模型详解
java·开发语言
小徐敲java21 小时前
python使用opcua的订阅和mqtt
开发语言·python
良木林21 小时前
Node.js基础:模块化与包
开发语言·前端·node.js
带土11 天前
1. Qt-的安装和环境变量的配置
开发语言·qt
q***d1731 天前
Rust并发模型
开发语言·后端·rust
CircleMouse1 天前
介绍几个axios接口请求顺序的问题
开发语言·前端·javascript·ecmascript
baivfhpwxf20231 天前
用TCP服务端向多个客户端分发图片,客户端接收并处理图片,再将处理结果返回给服务端
服务器·开发语言·网络·tcp/ip·c#
资深web全栈开发1 天前
Golang Cobra 教程:构建强大的CLI应用
开发语言·后端·golang
J***79391 天前
Python在机器学习中的数据处理
开发语言·python·机器学习