在Composer中使用自己修改的包

在使用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/igorw/monolog"
    },
]

如果自己的修改是直接提交到了master分支,那么直接修改composer.jsonrequire的相应包的版本为dev-master。也可以另外给自己的修改建独立分支。后续需要同步上游修改时,直接用git pull即可。

发布了16 篇原创文章 · 获赞 1 · 访问量 4680

猜你喜欢

转载自blog.csdn.net/TLingC/article/details/103446827