拉取 satis 項目包,並拉取項目依賴php
composer create-project composer/satis --stability=dev cd satis composer install
修改 satis/config.json 文件,文件內容以下html
{ "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壓縮包的方式直接下載包文件 } }
web/ 是本地倉庫訪問地址。nginx
php bin/satis build config.json web/
若是須要定時更新,則須要配置定時任務去定時更新git
nginx 設置虛擬主機github
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; } }
composer.json 文件中添加如下 json 拉取,便可獲取本地庫了.web
若是本地倉庫不存在且有網絡會去網絡中獲取。repositories 參數能夠設置多個json
{ "repositories": [{ "type": "composer", "url": "http://packages.example.org" }] }
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.
解決方法:segmentfault
訪問命令行中提示的 https://github.com/settings/t...windows
複製 token description 文本框中內容api
拉到頁底 點擊 generate token
在命令行中粘貼複製內容確認限可
解決方法:
本地生成 ssh key ,配置到要拉取項目的平臺便可,免密拉取了
ssh-keygen -t rsa cat ~/.ssh/id_rsa.pub
以 gogs 爲例
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.
解決方法:
composer config -g secure-http false
[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.
解決方法: