satis搭建composer私库成功update install笔记

小编上周五没搞定,遂存档问题期待专业人士指点。
satis搭建composer私库,折腾近两天没搞定。问题在哪里?
一周后,果有懂行玩家秉承互联网分享精神,于评论区、私信指导,小编静下心耐心折腾俩小时,终于解决问题。

成功执行 composer update,信息如下:

PS E:\code\v4> composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing yixzm/yix_composer (dev-master 25899c3): Cloning 25899c3b64 from cache
Writing lock file
Generating autoload files

回顾失败教训,做一整理。

1. git仓库准备

composer代码库,能正常clone。示例如:

git clone git@www.domain.com:/repo/yix_composer.git
Cloning into 'yix_composer'...
remote: Counting objects: 33, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 33 (delta 14), reused 0 (delta 0)
Receiving objects: 100% (33/33), done.
Resolving deltas: 100% (14/14), done.

注意:本文私库读者无法clone,所以用虚拟git地址
composer.json配置供参考:

{
    "name": "yixzm/yix_composer",
    "description": "202002281000",
    "type": "library",
    "license": "MIT",
    "authors": [
        {
            "name": "dream",
            "email": "dream@yixzm.cn"
        }
    ],
    "version": "1.1.1",
    "minimum-stability": "stable",
    "autoload": {
        "psr-4": {
            "Yix\\Utils\\": "src/"
        }
    },
    "require": {},
    "prefer-stable": true
}

2. composer私库创建

2.1 satis 安装

相当于搭建一个在线网站,好在小编有些储备。apache、composer、php等安装配置不再赘述。

在站点根目录,创建satis项目。相当于thinkphp的工程目录。

composer create-project composer/satis --stability=dev --keep-vcs

satis.json 配置

{
  "name": "yixzm/utils",
  "homepage": "https://composer.yixzm.cn/",
  "repositories": [
    {
      "type": "vcs",
      "url": "git@www.domain.com:/repo/yix_composer.git"
    }
  ],
  "require": {
    "yixzm/yix_composer": "master"
  }
}

一定注意 require 配置,这里有坑,小编栽了大跟头。这里的版本号 master 实际上是 Git 的分支名。

  • yixzm/yix_composer 是包名
  • master 是分支名

2.2 build public目录

命令

php bin/satis build satis.json public/

成功信息如下

# php bin/satis build satis.json public/
Scanning packages
Wrote packages to public//include/all$989a20d35d4868fd05f313331a59ea07112207dc.json
Writing packages.json
Pruning include directories
Deleted public//include/all$96e5c0926e9d7f87094d1ba307e38ea76cd09c53.json
Writing web view

至此,私库创建OK。
完成界面参考小编, 访问私库站点示例

使用测试

新建目录,创建 composer.json 文件,参考如下:

{
    "config": {
        "secure-http": false
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://composer.yixzm.cn/"
        }
    ],
    "require": {
        "yixzm/yix_composer": "dev-master"
    }
}

注意:这里小编又遇到了大坑。require配置中的 "dev-master",这个能从私库web网页看到。小编配错好几次……

composer update,测试会发现一切是那么的美好。

至此,satis搭建composer私库副本刷的很圆满。

版权声明

弈心博客


本文首发site_name,转载请附上博文链接!