前边有介绍以及运行过基于nexus proxy 模式的php composer(其中也有一些坑),以下是关于host 模式的
简单使用
环境准备
- docker-compose 文件
version: "3"
services:
nexus:
image: jbuncle/nexus-repository-composer
volumes:
- "./nexus-data:/nexus-data"
ports:
- "8081:8081"
- 启动&&配置
这个比较简单docker-compose up -d
- 添加host 模式的php composer
- 一个proxy 模式的composer
简单项目集成
- composer.json 文件
{
"config": {
"secure-http": false
},
"version": "1.0",
"name": "dalongdemo",
"description": "this is a demo composer repo",
"authors": [{
"name": "dalong",
"email": "1141591465@qq.com"
}],
"require": {
"monolog/monolog": "1.0.*",
"pugx/shortid-php":"v0.5.1"
},
"repositories": {
"packagist": {
"type": "composer",
"url": "http://localhost:8081/repository/demo/"
}
}
}
- 归档composer包
composer archive --format=zip
- 上传composer包
curl -v --user 'user:password' --upload-file dalongdemo-1.0.tar http://localhost:8081/repository/myhost-composer/packages/upload/dalongrong/dalongdemo/1.0
- 效果
引用发布的软件包
- 创建group 类型composer
- demo composer 项目
{
"config": {
"secure-http": false
},
"name": "dalong/dalong",
"authors": [
{
"name": "rongfengliang",
"email": "1141591465@qq.com"
}
],
"repositories": [
{
"type": "composer",
"url": "http://localhost:8081/repository/myphp-group/"
},
{
"packagist.org": false
}
],
"require": {
"dalongrong/dalongdemo":"1.0"
}
}
- 安装依赖
composer install --no-dev
Loading composer repositories with package information
Warning: Accessing localhost over http which is an insecure protocol.
Updating dependencies
Package operations: 8 installs, 0 updates, 0 removals
- Installing symfony/polyfill-mbstring (v1.12.0): Downloading (100%)
- Installing paragonie/random_compat (v2.0.18): Downloading (100%)
- Installing paragonie/sodium_compat (v1.12.1): Downloading (100%)
- Installing ircmaxell/security-lib (v1.1.0): Downloading (100%)
- Installing paragonie/random-lib (v2.0.0): Downloading (100%)
- Installing pugx/shortid-php (v0.5.1): Downloading (100%)
- Installing monolog/monolog (1.0.2): Downloading (100%)
- Installing dalongrong/dalongdemo (1.0): Downloading (100%)
Writing lock file
Generating autoload files
参考资料
https://github.com/sonatype-nexus-community/nexus-repository-composer
https://getcomposer.org/doc/03-cli.md#archive
https://github.com/rongfengliang/nexus-composer-learning
https://www.cnblogs.com/rongfengliang/p/11931524.html