composer私有仓库搭建之系列一:创建自己的私有仓库

1,260次阅读
没有评论

首先有自己的项目仓库,项目的composr.json配置如下

{
  "name": "test/packag1",
  "description": "私有仓库创建测试",
  "type": "library",
  "license": "proprietary",
  "minimum-stability": "dev",
  "require": {
    "ext-curl": "*",
    "ext-redis": "*",
    "ext-fileinfo": "*",
    "ext-libxml": "*",
    "ext-simpleXml": "*",
    "ext-json": "*",
    "monolog/monolog": "^1.25",
  },
  "keywords": [
    "test,library"
  ],
  "authors": [
    {
      "name": "joshua317",
      "email": "joshua317@joshua317.com",
      "role": "Master"
    }
  ],
  "repositories": {
    "composer.joshua317": {
      "type": "composer",
      "url": "http://composer.joshua317.com"
    }
  },
  "prefer-stable": true,
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true,
    "secure-http": false,
    "process-timeout": 120
  },
  "require-dev": {
    "phpunit/phpunit": "^9.0"
  }
}

一、使用 Satis 搭建私有仓库

使用 Composer 自带的建项目功能,这个相当于git clone+composer install+ 运行 post-install 脚本。

私有仓库的创建很简单,直接通过使用下面命令创建就可以

cd /data/wwwroot/
composer create-project composer/satis --stability=dev --keep-vcs  --no-secure-http

二、建立satis.json配置文件

上面命令完成后,进入到目录,进行satis.json文件的创建

{
    "name": "My Repository",
    "homepage": "http://composer.joshua317.com",
    "repositories": [
    {
        "type": "vcs",
        "url": "http://gitlab.joshua317.com/test/package1.git"
    }],
    "require":
    {
"test/package1": "dev-master"
    },
    "require-all": false,
    "archive":
    {
        "directory": "dist",
        "format": "tar",
        "skip-dev": true
    }
}

配置文件详解

name:仓库名字
homepage:主页地址
repositories:包所在地址
require:指定获取哪些包及对应的版本,获取所有包使用”require-all”: true,与包中composer.json中的名称相同,不同会出现问题

二、生成仓库及更新仓库列表

使用下面命令会生成一个public目录,里面有生成的所有包的信息,然后把这个目录设置到可以用域名访问的地方,比如  composer.joshua317.com

cd /data/wwwwoot/
php bin/satis build satis.json public/

也可以使用下面命令行生成指定包的信息

php bin/satis build satis.json public/ test/test1 test/test2

三、NGINX配置

server {
    listen  80;
    server_name composer.joshua317.com;
    index index.html index.php;
    root /home/wwwroot/satis/public;
    access_log /data/log/composer-access.log  default_access;
    error_log /data/log/composer-error.log  error;

    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;
    }  
}

服务起来后,浏览器输入:http://composer.joshua317.com 进行访问

四、使用私有仓库包

 在自己项目中的composer.json中添加类似如下内容

{
    "require":
    {
        "test/package1": "*"
    }
    "config":
    {
        "secure-http": false
    }
    "repositories":
    {
        "packagist":
        {
            "type": "composer",
            "url": "http://composer.joshua317.com"
        }
    }
}

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)

文心AIGC

2023 年 11 月
 12345
6789101112
13141516171819
20212223242526
27282930  
文心AIGC
文心AIGC
人工智能ChatGPT,AIGC指利用人工智能技术来生成内容,其中包括文字、语音、代码、图像、视频、机器人动作等等。被认为是继PGC、UGC之后的新型内容创作方式。AIGC作为元宇宙的新方向,近几年迭代速度呈现指数级爆发,谷歌、Meta、百度等平台型巨头持续布局
文章搜索
热门文章
潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026 Jay 2025-12-22 09...
“昆山杯”第二十七届清华大学创业大赛决赛举行

“昆山杯”第二十七届清华大学创业大赛决赛举行

“昆山杯”第二十七届清华大学创业大赛决赛举行 一水 2025-12-22 17:04:24 来源:量子位 本届...
MiniMax海螺视频团队首次开源:Tokenizer也具备明确的Scaling Law

MiniMax海螺视频团队首次开源:Tokenizer也具备明确的Scaling Law

MiniMax海螺视频团队首次开源:Tokenizer也具备明确的Scaling Law 一水 2025-12...
天下苦SaaS已久,企业级AI得靠「结果」说话

天下苦SaaS已久,企业级AI得靠「结果」说话

天下苦SaaS已久,企业级AI得靠「结果」说话 Jay 2025-12-22 13:46:04 来源:量子位 ...
最新评论
ufabet ufabet มีเกมให้เลือกเล่นมากมาย: เกมเดิมพันหลากหลาย ครบทุกค่ายดัง
tornado crypto mixer tornado crypto mixer Discover the power of privacy with TornadoCash! Learn how this decentralized mixer ensures your transactions remain confidential.
ดูบอลสด ดูบอลสด Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Obrazy Sztuka Nowoczesna Obrazy Sztuka Nowoczesna Thank you for this wonderful contribution to the topic. Your ability to explain complex ideas simply is admirable.
ufabet ufabet Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
ufabet ufabet You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
ufabet ufabet Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
热评文章
摩尔线程的野心,不藏了

摩尔线程的野心,不藏了

摩尔线程的野心,不藏了 量子位的朋友们 2025-12-22 10:11:58 来源:量子位 上市后的仅15天...
摩尔线程的野心,不藏了

摩尔线程的野心,不藏了

摩尔线程的野心,不藏了 量子位的朋友们 2025-12-22 10:11:58 来源:量子位 上市后的仅15天...
AI体育教练来了!中国团队打造SportsGPT,完成从数值评估到专业指导的智能转身

AI体育教练来了!中国团队打造SportsGPT,完成从数值评估到专业指导的智能转身

AI体育教练来了!中国团队打造SportsGPT,完成从数值评估到专业指导的智能转身 量子位的朋友们 2025...
AI体育教练来了!中国团队打造SportsGPT,完成从数值评估到专业指导的智能转身

AI体育教练来了!中国团队打造SportsGPT,完成从数值评估到专业指导的智能转身

AI体育教练来了!中国团队打造SportsGPT,完成从数值评估到专业指导的智能转身 量子位的朋友们 2025...
真正面向大模型的AI Infra,必须同时懂模型、系统、产业|商汤大装置宣善明@MEET2026

真正面向大模型的AI Infra,必须同时懂模型、系统、产业|商汤大装置宣善明@MEET2026

真正面向大模型的AI Infra,必须同时懂模型、系统、产业|商汤大装置宣善明@MEET2026 量子位的朋友...