使用 satis 搭建 composer 本地仓库
环境
- windows
- nginx
- php
- composer
安装
拉取 satis 项目包,并拉取项目依赖
```
composer create-project composer/satis --stability=dev
cd satis
composer install
<h2>配置</h2>
<p>修改 satis/config.json 文件,文件内容如下</p>
{
"name": "composer 本地仓库",
"homepage": "http://packages.example.org", // 访问域名
"repositories": [// 要拉取包的仓库地址
{ "type": "vcs", "url": "https://github.com/test-lin/db.git" },
{ "type": "vcs", "url": "https://github.com/test-lin/queue.git" },
{ "type": "vcs", "url": "https://github.com/test-lin/cache.git" },
{ "type": "vcs", "url": "http://192.168.6.251:3000/php/xjwSpider.git" }
],
"require": { // 要拉取到本地的包文件 注:不会包含包的依赖
"test-lin/db": "",
"test-lin/queue": "",
"test-lin/cache": "",
"php/xjwSpider": ""
},
"archive": {
"directory": "dist",
"format": "tar",
"prefix-url": "http://packages.example.org" // * 这个参数是当前项目的域名,作用是以zip压缩包的方式直接下载包文件
}
}
<h2>拉取包到本地仓库</h2>
<p>web/ 是本地仓库访问地址。</p>
php bin/satis build config.json web/
<p>如果需要定时更新,则需要配置定时任务去定时更新</p>
<h2>设置本地仓库</h2>
<p>nginx 设置虚拟主机</p>
server {
listen 80;
server_name packages.example.org;
root /var/www/satis/web;
index index.php index.html;
location ~* \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
<h2>使用本地仓库中的包</h2>
<p>composer.json 文件中添加以下 json 拉取,即可获取本地库了.</p>
<p>如果本地仓库不存在且有网络会去网络中获取。repositories 参数可以设置多个</p>
{
"repositories": [{
"type": "composer",
"url": "http://packages.example.org"
}]
}
<h2>FQA</h2>
<h3>1. github 的包需要配置 token</h3>
Could not fetch https://api.github.com/repos/test-lin/db/git/refs/heads?per_page=100, please create a GitHub OAuth token to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+packages.example.org+2018-06-28+0310
to retrieve a token. It will be stored in "/home/vagrant/.config/composer/auth.json" for future use by Composer.
<p>解决方法:</p>
<p>访问命令行中提示的 <a href="https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+packages.example.org+2018-06-28+0310" rel="nofollow noreferrer">https://github.com/settings/t...</a></p>
<p>复制 token description 文本框中内容</p>
<p>拉到页底 点击 generate token</p>
<p>在命令行中粘贴复制内容确认限可</p>
<h3>2. 私有包,拉取不了</h3>
<p>解决方法:</p>
<p>本地生成 ssh key ,配置到要拉取项目的平台即可,免密拉取了</p>
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub
<p>以 gogs 为例</p>
![](https://img2018.cnblogs.com/blog/1504257/201811/1504257-20181116160341342-710905133.jpg)
<h3>3. composer 不支持 http</h3>
Your configuration does not allow connections to http://192.168.6.251:3000/php/xjwSpider.git. See https://getcomposer.org/doc/06-config.md#secure-http for details.
<p>解决方法:</p>
composer config -g secure-http false
<h3>4. 拉取的包 composer.json 配置有误</h3>
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of http://192.168.6.251:3000/php/xjwSpider.git, could not load a package from it.
<p>解决方法:</p>
<ol>
<li>确保项目根部有 composer.json</li>
<li>composer.json 里需要设置 name</li>
</ol>
原文地址:https://segmentfault.com/a/1190000016523278
最新文章
- [Hadoop in Action] 第2章 初识Hadoop
- [LeetCode] Search a 2D Matrix II 搜索一个二维矩阵之二
- java运算符
- luogu2038[NOIP2014 T4]无线网络发射器选址
- Robot framework + appium环境搭建
- Android双向滑动菜单完全解析,教你如何一分钟实现双向滑动特效
- MQ集群测试环境搭建(多节点负载均衡,共享一个kahaDB文件(nas方式))
- CF192div2-330B - Road Construction
- 注意 reader[";yjID";] == DBNull.Value而不是null
- 年度钜献,108个大数据文档PDF开放下载
- Hive 行列转换
- XJOI1595空中楼阁【最短路】
- html5 01 随记
- 机器学习之Logistic 回归算法
- 土旦:关于display:flex碰上white-space nowrap 影响布局的问题
- 什么是车辆识别代码(VIN)
- c#获取汉字首字母拼音
- hdu5443 ST表裸题:求区间最大
- Spring Batch框架流程的简单介绍
- OpenVPN相同证书不同客户端设置不同静态IP的问题
热门文章
- django rest-farme-work 的使用(2)
- C++ constexpr类型说明符
- SVN文件恢复
- Tomcat学习之ClassLoader
- C# 监控Windows睡眠与恢复
- 2015.03.16,外语,读书笔记-《Word Power Made Easy》 00 “如何最大限度的利用本书”学习笔记
- hdoj--5240--Exam()
- Windows下Word.exe在哪?
- 关于HTML与CSS与class
- caffe下python环境的编译