nexus php composer 私服搭建
nexus 社区也提供了php composer 私服(当前还在开发中,还没有ga),测试使用构建好的docker 镜像
环境准备
- docker-compose 文件
version: "3"
services:
nexus:
image: jbuncle/nexus-repository-composer:2.0.0
volumes:
- "./nexus-data:/nexus-data"
ports:
- "8081:8081"
- 启动
docker-compose up -d
- 配置nexus
按照提示即可,很简单 - 添加composer proxy
使用
- 安装composer
mac 系统
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
- 初始化composer 项目
composer.json 文件
{
"config": {
"secure-http": false
},
"require": {
"monolog/monolog": "1.0.*"
},
"repositories": {
"packagist": {
"type": "composer",
"url": "http://localhost:8081/repository/demo/"
}
}
}
- 安装依赖
composer install
- 效果
nexus local cache
说明
在测试proxy 阿里云,华为云以及几个国内镜像发现没有成功 ,但是直接代理官方的没有问题
参考资料
https://hub.docker.com/r/jbuncle/nexus-repository-composer
https://pkg.phpcomposer.com/
https://getcomposer.org/doc/06-config.md#secure-http
https://packagist.org/mirrors