用 Satis 处理私有资源包

Satis is a static composer repository generator. It is a bit like an ultra-

lightweight, static file-based version of packagist and can be used to host the

metadata of your company's private packages, or your own. It basically acts as

a micro-packagist. You can get it from

GitHub or install via CLI:

composer.phar create-project composer/satis --stability=dev.

Satis 是一个静态的 composer 代码库生成器。

Setup

For example let's assume you have a few packages you want to reuse across your

company but don't really want to open-source. You would first define a Satis

configuration: a json file with an arbitrary name that lists your curated

repositories.

Here is an example configuration, you see that it holds a few VCS repositories,

but those could be any types of repositories. Then it

uses "require-all": true which selects all versions of all packages in the

repositories you defined.

The default file Satis looks for is satis.json in the root of the repository.

{

"name": "My Repository",

"homepage": "http://packages.example.org",

"repositories": [

{ "type": "vcs", "url": "http://github.com/mycompany/privaterepo" },

{ "type": "vcs", "url": "http://svn.example.org/private/repo" },

{ "type": "vcs", "url": "http://github.com/mycompany/privaterepo2" }

],

"require-all": true

}

If you want to cherry pick which packages you want, you can list all the packages

you want to have in your satis repository inside the classic composer require key,

using a "*" constraint to make sure all versions are selected, or another

constraint if you want really specific versions.

{

"repositories": [

{ "type": "vcs", "url": "http://github.com/mycompany/privaterepo" },

{ "type": "vcs", "url": "http://svn.example.org/private/repo" },

{ "type": "vcs", "url": "http://github.com/mycompany/privaterepo2" }

],

"require": {

"company/package": "*",

"company/package2": "*",

"company/package3": "2.0.0"

}

}

Once you did this, you just run php bin/satis build .

For example php bin/satis build config.json web/ would read the config.json

file and build a static repository inside the web/ directory.

When you ironed out that process, what you would typically do is run this

command as a cron job on a server. It would then update all your package info

much like Packagist does.

Note that if your private packages are hosted on GitHub, your server should have

an ssh key that gives it access to those packages, and then you should add

the --no-interaction (or -n) flag to the command to make sure it falls back

to ssh key authentication instead of prompting for a password. This is also a

good trick for continuous integration servers.

Set up a virtual-host that points to that web/ directory, let's say it is

packages.example.org. Alternatively, with PHP >= 5.4.0, you can use the built-in

CLI server php -S localhost:port -t satis-output-dir/ for a temporary solution.

Usage

In your projects all you need to add now is your own composer repository using

the packages.example.org as URL, then you can require your private packages and

everything should work smoothly. You don't need to copy all your repositories

in every project anymore. Only that one unique repository that will update

itself.

{

"repositories": [ { "type": "composer", "url": "http://packages.example.org/" } ],

"require": {

"company/package": "1.2.0",

"company/package2": "1.5.2",

"company/package3": "dev-master"

}

}

Security

To secure your private repository you can host it over SSH or SSL using a client

certificate. In your project you can use the options parameter to specify the

connection options for the server.

Example using a custom repository using SSH (requires the SSH2 PECL extension):

{

"repositories": [

{

"type": "composer",

"url": "ssh2.sftp://example.org",

"options": {

"ssh2": {

"username": "composer",

"pubkey_file": "/home/composer/.ssh/id_rsa.pub",

"privkey_file": "/home/composer/.ssh/id_rsa"

}

}

}

]

}

Tip: See ssh2 context options for more information.

Example using HTTP over SSL using a client certificate:

{

"repositories": [

{

"type": "composer",

"url": "https://example.org",

"options": {

"ssl": {

"local_cert": "/home/composer/.ssl/composer.pem"

}

}

}

]

}

Tip: See ssl context options for more information.

Downloads

When GitHub or BitBucket repositories are mirrored on your local satis, the build process will include

the location of the downloads these platforms make available. This means that the repository and your setup depend

on the availability of these services.

At the same time, this implies that all code which is hosted somewhere else (on another service or for example in

Subversion) will not have downloads available and thus installations usually take a lot longer.

To enable your satis installation to create downloads for all (Git, Mercurial and Subversion) your packages, add the

following to your satis.json:

{

"archive": {

"directory": "dist",

"format": "tar",

"prefix-url": "https://amazing.cdn.example.org",

"skip-dev": true

}

}

Options explained

directory: the location of the dist files (inside the output-dir)

format: optional, zip (default) or tar

prefix-url: optional, location of the downloads, homepage (from satis.json) followed by directory by default

skip-dev: optional, false by default, when enabled (true) satis will not create downloads for branches

Once enabled, all downloads (include those from GitHub and BitBucket) will be replaced with a local version.

prefix-url

Prefixing the URL with another host is especially helpful if the downloads end up in a private Amazon S3

bucket or on a CDN host. A CDN would drastically improve download times and therefore package installation.

Example: A prefix-url of http://my-bucket.s3.amazonaws.com (and directory set to dist) creates download URLs

which look like the following: http://my-bucket.s3.amazonaws.com/dist/vendor-package-version-ref.zip.

Resolving dependencies

It is possible to make satis automatically resolve and add all dependencies for your projects. This can be used

with the Downloads functionality to have a complete local mirror of packages. Just add the following

to your satis.json:

{

"require-dependencies": true

}

When searching for packages, satis will attempt to resolve all the required packages from the listed repositories.

Therefore, if you are requiring a package from Packagist, you will need to define it in your satis.json.

如果您发现文档中有错误,或者能够帮我们完善文档,请提交到我们的 Github 仓库吧!

php composer 私有包,用 Satis 处理私有资源包相关推荐

  1. Yii资源包加载JS/CSS

    1.资源包 Yii 在资源包中管理资源,资源包简单的说就是放在一个目录下的资源集合, 当在视图中注册一个资源包, 在渲染 Web 页面时会包含包中的 CSS 和 JavaScript 文件. 2.定义 ...

  2. vivo 官网资源包适配多场景的应用

    本文介绍了资源包的概念及使用场景,同时对资源包的几种使用方案进行对比.通过本文,大家可以快速掌握资源包的使用方法,解决单一配置满足多场景.多样式的问题. 一.业务背景 随着官网项目的业务深入发展,单纯 ...

  3. Unity资源包共享

    unity最全材质球的资源包 unity家具包装设计资源包 unity游戏模型资源包 unity人物模型资源包 unity枪模型资源包 - - - 其中一部分 有需要的朋友下方评论留下邮箱号,我发给你 ...

  4. iOS开发实现资源包增量更新

      所谓资源包的增量更新是指,比如有一个资源包1.0版本, 现在如果升级到1.1本,那么只需要将1.0的版本信息发送给服务端,服务器端返回一个差分包.将这个差分包和本地的1.0的资源包进行合并生成1. ...

  5. 阿里云证书资源包申请免费SSL流程(图文教程)

    阿里云SSL免费证书2021更新,需要在云盾证书资源包处选择免费证书扩容包,资源包个数20,新手站长网来详细说下阿里云免费SSL证书从购买到申请全过程: 阿里云免费SSL证书申请教程 2021阿里云S ...

  6. Java 对国际化 (i18n) 的支持资源包的调用

    Java 国际化 i18n 国际化信息也成为本地化信息,一般需要2个条件才能确定一个特定的国际化信息,分别是:"语言类型" 和 "国家/地区信息",Java 为 ...

  7. 我的世界javaui材质包怎么下载_我的世界材质包怎么用 资源包下载安装教程

    我的世界中的资源包和材质包其实是同一个类型的物品,资源包(Resource pack)系统为材质包系统的API代替物,允许玩家更深度地自定义自己的Minecraft体验.资源包允许玩家自定义音乐.音效 ...

  8. 我的世界Bukkit服务器插件开发教程(十三)资源包与玩家资料

    十三.资源包与玩家资料 1.资源包(Resource Pack) 早期的 Minecraft 并没有资源包一说,而是被叫做材质包.有些服务器为了让玩家拥有更好的游戏体验,一般会在自己特制的客户端中存放 ...

  9. composer satis 处理私有资源包

    satis satis 是一个静态的 composer 代码库生成器.他可以提供私有资源包更新服务: 安装 首先保证已经安装了composer: 然后到web根目录: composer create- ...

最新文章

  1. ODBC更新记录集提示”记录集为只读“
  2. BeanUtils解决日期问题
  3. 在哪里能收到python实例代码-Python分类测试代码实例汇总
  4. linux脚本好难,如何做才能学好Shell脚本的经验总结
  5. 每个开发人员现在应该下载的十种必备工具
  6. 你,的寒假作业写多少了?
  7. 利用OpenCV的Haar特征目标检测方法进行人脸识别的尝试(一)
  8. Gulp简介、gulp基本使用步骤、gulp-cli工具、gulpfile.js文件、gulp插件
  9. wpf 轮询mysql数据库_WPF非轮询方式实时更新数据库变化SqlDependency
  10. Java 已老,Kotlin 或将取而代之!
  11. OpenAI API 案例
  12. 子级Repeater获取 父级Repeater 中的值
  13. python课题_python课题报告
  14. 4级网络工程师第5套知识点
  15. 博世中国的战略与战术,如何应对复杂多变的中国市场需求
  16. 日本艺伎的拍照姿势,竟源于孔子?看完真的涨知识···
  17. 2021校招offer薪资如何?(包含当今互联网各巨厂、大厂、中厂)
  18. 测序数据分析之OTU
  19. 这篇文章告诉你:信息学奥赛的由来,几岁学对孩子有多重要性
  20. 转载:js和as间的交互

热门文章

  1. AutoCAD的显示界面调佣
  2. 2022-2028年全球与中国人脸访客登记机行业产销需求与投资预测分析
  3. 基于轮廓提取的 图像填充法
  4. pytorch安装错误
  5. 由尚德linux系统编程录,linux系统编程(由尚德)
  6. 【教程】易度文档系统-查看和播放
  7. 2022认证杯(小美赛)D题详细思路
  8. 清空mailq 队列里面的邮件
  9. 前端 JavaScript -- 键盘按下松开事件
  10. 关于苹果iOS13的所有设计规范