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

相关推荐
Tony Bai1 天前
高并发后端:坚守 Go,还是拥抱 Rust?
开发语言·后端·golang·rust
小虎哥-技术博客1 天前
ThinkPHP 5.x 到 8.x 行为扩展迁移指南
php
wjs20241 天前
Swift 类型转换
开发语言
秃了也弱了。1 天前
python实现定时任务:schedule库、APScheduler库
开发语言·python
weixin_440730501 天前
java数组整理笔记
java·开发语言·笔记
Thera7771 天前
状态机(State Machine)详解:原理、优缺点与 C++ 实战示例
开发语言·c++
niucloud-admin1 天前
java服务端——controller控制器
java·开发语言
夏幻灵1 天前
JAVA基础:基本数据类型和引用数据类型
java·开发语言
cike_y1 天前
Spring-Bean的作用域&Bean的自动装配
java·开发语言·数据库·spring
十八度的天空1 天前
第01节 Python的基础语法
开发语言·python