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

相关推荐
2601_9657984711 小时前
Salient Theme Setup Guide for Fast Creative WordPress Sites
数据库·web3·php·wordpress
CRMEB定制开发12 小时前
2026年最值得推荐的10大开源商城系统盘点
开发语言·人工智能·开源·商城系统·小程序商城
buhuizhiyuci13 小时前
【QT-百日筑基篇】修真世界摸爬滚打多年,终于黄天不负有心人,突破炼器中期——常用控件QWight的属性
开发语言·c++·qt·gui·图形化
Littlehero_12114 小时前
QT自定义控件之热换站系统(源码开源)
开发语言·qt
meilindehuzi_a14 小时前
Python 基础语法(1):常量、变量、类型、输入输出与运算符
开发语言·python
caimouse14 小时前
ReactOS 窗口系统分析(5):可见区域与窗口 DC — vis.c + windc.c
c语言·开发语言
OPEN-F15 小时前
Python进阶教程:装饰器与生成器深入
开发语言·python
千里码aicood16 小时前
基于Python的电商数据采集系统(大数据+爬虫)
开发语言·python
福大大架构师每日一题16 小时前
ragflow v0.27.0 发布:Go 后端全面对齐、智能体搜索与知识编译大升级,超全更新解析
开发语言·后端·golang
陈皮波比茶16 小时前
Python项目实战-网络机器人(爬虫)
开发语言·网络·爬虫·python·机器人