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

相关推荐
代码改善世界4 分钟前
【C++初阶】string类(一):从基础到实战
开发语言·c++
计算机安禾5 分钟前
【数据结构与算法】第15篇:队列(二):链式队列的实现与应用
c语言·开发语言·数据结构·c++·学习·算法·visual studio
Leventure_轩先生6 分钟前
[RL]强化学习指导搭建IC2E核反应堆
开发语言·php
zzginfo18 分钟前
var、let、const、无申明 四种变量在赋值前,使用的情况
开发语言·前端·javascript
csdn_aspnet38 分钟前
C++ 求n边凸多边形的对角线数量(Find number of diagonals in n sided convex polygon)
开发语言·c++·算法
wsoz40 分钟前
快速从C过渡到C++
c语言·开发语言·c++
深邃-1 小时前
字符函数和字符串函数(1)
c语言·开发语言·数据结构·c++·算法·html5
初中就开始混世的大魔王1 小时前
3.1 DDS 层-Core
开发语言·c++·网络协议·tcp/ip·信息与通信