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

相关推荐
zuowei288918 小时前
华为网络设备配置文件备份与恢复(上传、下载、导出,导入)
开发语言·华为·php
xiaohe0718 小时前
超详细 Python 爬虫指南
开发语言·爬虫·python
嗑嗑嗑瓜子的猫18 小时前
Java!它值得!
java·开发语言
xiaoshuaishuai819 小时前
C# GPU算力与管理
开发语言·windows·c#
lsx20240619 小时前
SVN 创建版本库
开发语言
xiaotao13119 小时前
01-编程基础与数学基石:Python错误与异常处理
开发语言·人工智能·python
皮卡蛋炒饭.20 小时前
线程的概念和控制
java·开发语言·jvm
John.Lewis20 小时前
Python小课(1)认识Python
开发语言·python
一只大袋鼠20 小时前
MyBatis 入门详细实战教程(一):从环境搭建到查询运行
java·开发语言·数据库·mysql·mybatis
sonnet-102920 小时前
函数式接口和方法引用
java·开发语言·笔记