用satis搭建私有镜像composer仓库

安装satis & 创建索引页

composer create-project composer/satis --keep-vcs

域名解析,指向  /satis/web 目录

配置satis.json

{
    "name": "kiwi's satis packages",
    "homepage": "http://composer.domain.com",
    "repositories": [
        { "type": "vcs", "url": "git@gitlab.gitdomain.cn:z3/hello.git" },
        { "type": "vcs", "url": "https://github.com/Kiwi0921/world.git" },
        { "type": "vcs", "url": "https://github.com/Kiwi0921/httpclient.git" }
     ],
     "require":{
        "z3/hello":"*",
        "Kiwi0921/world":"*",
        "Kiwi0921/httpclient":"*"
     }
}

创建索引

php bin/satis build satis.json ./web -v   #-v参数可以看到被索引的包

遇到的问题

问题一: 配置的sdk项目根目录需要配置一个composer.json 文件

创建一个composer.json ,push到github仓库

{
	"name":"Kiwi0921/httpclient",
	"autoload":{
		"psr-4": {"kiwi\\httpclient\\": "src/"}     
	}
}

遇到的坑,autoload : psr-4 参数随便写了个,导致项目中命名空间无法找到项目,new 之后一直not found!!psr-4 是一个类自动加载的规则(https://www.php-fig.org/psr/psr-4/)这里必须和命名空间同步,上面写的kiwi\\httpclient是错误的, 必须改成类库使用的关键词 http,  在 vendor/composer/autoload_psr4.php文件中会有如下映射关系,http才会正确找到类库的路径

return array(
	'http\\' => array($vendorDir . '/fkiwisdk/httpclient/src'),
);

 

问题二: 提示github需要一个token, 在git个人中心生成一个token,创建索引需要输入

问题三: php.ini memory_limit 太小 默认128M 修改为512M , 重启nginx

创建索引成功,就可以看到composer仓库页

composer使用我的仓库

配置composer.json 文件

{
  "repositories": [{
    "type": "composer",
    "url": "http://composer.fkiwi.com"
  }],
  "require": {
        "kiwi0921/httpclient": "dev-master",
	"z3/hello": "dev-master"
    },
  "config": {
    "secure-http": false
  }
}

执行

composer install

提示  Your configuration does not allow connections to http://composer.mydomain.com/
packages.json. See https://getcomposer.org/doc/06-config.md#secure-http for
details.

修改配置,默认禁用https请求

 composer config secure-http false

全局设置:

composer config -g secure-http false

继续执行  composer install, 但是10多分钟后依然出错

The “http://packagist.org/p/provider-2018-01%242e0c884ed3d0e1e91e46bce59489
3ae4c264ae35bde9e03917cff93bb704703a.json” file could not be downloaded (HT
TP/1.1 404 Not Found)

待解决

 

gitbug  -> Organizations

 

 

 

-end-

发表评论