Table of contents
No headings in the article.
场景:本地开发一个composer package,但是不需要公开或还没发版,但又想在其他项目A中依赖它来使用。
示例:
...
├--- apps
│ └── my-app
│ └── composer.json
├--- packages
│ └── my-package
│ └── composer.json
...
apps/my-app
项目依赖 packages/my-package
,在apps/my-app/composer.json
中添加一下内容
{
"repositories": [
{
"type": "path",
"url": "../../packages/my-package"
}
],
"require": {
"my/package": "*"
}
}
如果my-package
是 git 仓库,则需要指定其分支,例如分支是master
,则版本为dev-master
,需要以dev-
开头,默认是dev-master
{
"repositories": [
{
"type": "path",
"url": "../../packages/my-package"
}
],
"require": {
"my/package": "dev-master"
}
}
或其他格式
{
"require": {
"jayin/ipgeo": "dev-master"
},
"repositories": {
"ipgeo": {
"type": "path",
"url": "/Users/jayinton/project/IpGeo"
}
}
}
安装/卸载
# 安装
$ composer require jayin/ipgeo:dev-master
# 卸载
$ composer remove jayin/ipgeo
参考:
- composer 文档: getcomposer.org/doc/05-repositories.md#path