composer私有仓库搭建

安装satis包

  • cd /home/wwwroot/
  • composer create-project composer/satis --stability=dev --keep-vcs

添加配置文件

  • cd satic
  • vim satis.json添加类似如下内容
{
    "name": "My Repository",
    "homepage": "http://59.110.107.59",
    "repositories": [
        {"type": "vcs", "url": "https://github.com/bambooleaf/reps_demo.git"},
        {"type": "vcs", "url": "https://github.com/isunshines/hello-world.git"}
    ],
    "require":{
        "reps_demo/helloworld":"*",
        "isunshines/hellow-world":"*"
    },
    "archive":{
        "directory":"dist",
        "format":"tar",
        "prefix-url":"http://59.110.107.59/",
        "skip-dev":true
    }
}

配置文件详解

  • name:仓库名字
  • homepage:主页地址
  • repositories:包所在地址
  • require:指定获取哪些包及对应的版本,获取所有包使用"require-all": true,与包中composer.json中的名称相同,不同会出现问题
  • directory: 必需要的,表示生成的压缩包存放的目录,会在build时的目录中
  • format: 压缩包格式, zip(默认)和tar
  • prefix-url: 下载链接的前缀的Url,默认会从homepage中取
  • skip-dev: 默认为假,是否跳过开发分支
  • absolute-directory: 绝对目录
  • whitelist: 白名单,只下载哪些
  • blacklist: 黑名单,不下载哪些
  • checksum: 可选,是否验证sha1

生成站点

  • bin/satis build satis.json ./public

服务配置

  • PHP服务器设置

    • php -S 127.0.0.1:8080 -t ./public
  • Nginx服务配置类似如下内容

    server {
        listen  80;
        server_name 59.110.107.59;
        index index.html index.php;
        root /home/wwwroot/satis/public;
        
        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        access_log  /home/wwwlogs/59.110.107.59-access.log  default_access;
        error_log /home/wwwlogs/59.110.107.59-error.log  error;
    }

查看私有仓库是否可以访问

图片描述

composer配置

  • composer config -g secure-http false

使用私有仓库包

  • 在自己项目中的composer.json中添加类似如下内容
{
  "repositories": [
      {"type": "composer","url": "http://59.110.107.59"}
  ],
  "config": {
      "secure-http": false
  },
  "require":{
      "reps_demo/helloworld":"*",
      "isunshines/hellow-world":"*"
  }
}
  • 创建项目

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值