溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么快速搭建composer

發(fā)布時間:2021-08-03 15:44:16 來源:億速云 閱讀:227 作者:chen 欄目:軟件技術

這篇文章主要介紹“怎么快速搭建composer”,在日常操作中,相信很多人在怎么快速搭建composer問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么快速搭建composer”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

搭建composer內網代碼倉庫

拉取 composer/satis 鏡像

docker pull composer/satis

配置 composer

該步驟可跳過

目錄結構

├── auth.json
├── cache
│   ├── files
│   ├── repo
│   └── vcs
├── composer.json
└── config.json
composer.json
{
}
config.json
{
    "config": {
        "secure-http": false,
        "optimize-autoloader": false,
        "preferred-install": "dist",
        "sort-packages": true,
        "platform": {
        }
    },
    "repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer/"
        }
    }
}

構建模塊擴展

目錄結構

├── config.json
├── public
│   ├── dist
│   │   ├── bpc
│   │   └── zhanghuizong
│   ├── include
│   │   └── all$f3811758e4611a4dfc1a96f4d1c06da09cdbe199.json
│   ├── index.html
│   └── packages.json
└── satis.sh

config.json

{
    "name": "composer_satis_test",
    "homepage": "http://local.satis.com",
    "repositories": [
        {
            "type": "git",
            "name": "zhanghuizong/composer_satis_test",
            "url": "https://gitee.com/zhanghuizong/composer_satis_test.git"
        }
    ],
    "require": {
        "zhanghuizong/composer_satis_test": "*"
    },
    "archive": {
        "directory": "dist",
        "format": "tar",
        "skip-dev": true,
        "prefix-url": "http://local.satis.com"
    }
}
關鍵詞描述
repositories指定去哪獲取包
require指定獲取哪些包,如果想獲取所有包,使用require-all: true
archive.directoryoutput-dir 即使build的輸出目錄
archive.format可選,默認:zip, 支持兩種壓縮格式:zip,tar。build時采用的壓縮格式
archive.skip-dev可選,默認情況下為false,啟用時(true)satis不會為分支機構創(chuàng)建下載
archive.prefix-url可選的下載位置,主頁(來自satis.json),默認情況下是目錄
官網說明:https://docs.phpcomposer.com/articles/handling-private-packages-with-satis.html
GitHub代碼:https://github.com/composer/satis

shell 腳本

satis.sh

#!/usr/bin/env bash

docker run --rm --init -it -v "$(pwd)"/config.json:/satis.json:ro \
-v "$(pwd)"/public/:/build \
-v /mnt/d/workspaces/docker-config/composer/:/composer \
composer/satis build /satis.json /build "$@"

增加快捷訪問

編輯文件:vi ~/.bashrc

alias satis='docker run --rm --init -it -v "$(pwd)"/config.json:/satis.json:ro -v "$(pwd)"/public/:/build -v /mnt/d/workspaces/docker-config/composer/:/composer composer/satis build /satis.json /build'

用法

# 構建所有代碼倉庫模塊
sh satis.sh

# 安裝指定模塊
sh satis.sh zhanghuizong/composer_satis_test

注意

指定模塊安裝,repositories 節(jié)點中必須配置 name 字段,同時與 require 節(jié)點配置對應上

nginx 配置

server {
        listen        80;
        server_name  local.satis.com;
        root   "/data/httpd/docker-config/composer_satis/test/public/";
        location / {
            index index.php index.html;
        }

        location ~ \.php(.*)$ {
            fastcgi_pass   php:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

到此,關于“怎么快速搭建composer”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注億速云網站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI