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

相关推荐
云天徽上6 分钟前
【数据可视化-112】使用PyEcharts绘制TreeMap(矩形树图)完全指南及电商销售数据TreeMap绘制实战
开发语言·python·信息可视化·数据分析·pyecharts
悠悠~飘11 分钟前
php学习(第五天)
学习·php
NG WING YIN1 小时前
Golang關於信件的
开发语言·深度学习·golang
Sunny_yiyi1 小时前
Java根据模版导出PDF文件
java·开发语言·pdf
橘子131 小时前
C++实战:搜索引擎项目(二)
开发语言·c++·搜索引擎
赵谨言2 小时前
基于python人物头像的卡通化算法设计与实现
开发语言·经验分享·python
应用市场2 小时前
Qt C++ 图形绘制完全指南:从基础到进阶实战
开发语言·c++·qt
楼田莉子2 小时前
python小项目——学生管理系统
开发语言·python·学习
yuanpan2 小时前
使用Python创建本地Http服务实现与外部系统数据对接
开发语言·python·http
bkspiderx2 小时前
C++时区操作全版本指南(含C++03/C++11-17/C++20)
linux·开发语言·c++·c++20·时区