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

相关推荐
鲸渔几秒前
【C++ 输入输出】cin、cout、cerr 与格式化输出
开发语言·c++·算法
3GPP仿真实验室3 分钟前
【MATLAB源码】水声:时变信道估计仿真平台
开发语言·matlab
froginwe113 分钟前
Eclipse 关闭项目详解
开发语言
wjs20245 分钟前
《jQuery Validate》深度解析与应用指南
开发语言
橘子编程9 分钟前
编程语言全指南:从C到Rust
java·c语言·开发语言·c++·python·rust·c#
我送炭你添花10 分钟前
边走边聊 Python 3.8:Win7 从入门到高手(目录)
开发语言·python
w_t_y_y10 分钟前
工具篇(一)机器学习常用的python包
开发语言·python·信息可视化
夜珀11 分钟前
OpenTiny NEXT 从入门到精通·第 3 篇
开发语言
代龙涛12 分钟前
WordPress 首页模板怎么写(index.php 与 front-page.php)
android·php·android studio
lly20240617 分钟前
Node.js 文件系统
开发语言