ffraenz/private-composer-installer
Composer 安装命令:
composer require ffraenz/private-composer-installer
包简介
A composer install helper for private packages
README 文档
README
This is a Composer plugin offering a way to reference private package URLs within composer.json and composer.lock. It outsources sensitive dist URL parts (license keys, tokens) into environment variables or a .env file typically ignored by version control. This is especially useful when you can't use Private Packagist or Basic HTTP Auth because the source of a package is not in your control. This repository is inspired by acf-pro-installer.
Quick overview
- This plugin is compatible with both Composer 2.x (latest) and 1.x.
- When installing or updating a package, the dist URL
{%VERSION}placeholder gets replaced by the version set in the package. In Composer 1 the dist URL version gets fulfilled before it is added tocomposer.lock. - Before downloading the package,
{%VARIABLE}formatted placeholders get replaced by their corresponding environment variables in the dist URL. Env vars will never be stored insidecomposer.lock. - If an environment variable is not available for the given placeholder the plugin trys to read it from the
.envfile in the working directory or in one of the parent directories. The.envfile gets parsed by vlucas/phpdotenv. - If an environment variable can't be resolved a
MissingEnvExceptiongets thrown. - Package dist URLs with no
{%VARIABLE}formatted placeholders get ignored by this plugin.
Examples
Arbitrary private packages
Add the desired private package to the repositories field inside composer.json. Find more about Composer repositories in the Composer documentation. Specify the exact version to install, and use {%VARIABLE} placeholders to specify any sensitive tokens in your .env file.
{
"type": "package",
"package": {
"name": "package-name/package-name",
"version": "REPLACE_WITH_LATEST_PACKAGE_VERSION",
"dist": {
"type": "zip",
"url": "https://example.com/package-name.zip?key={%PACKAGE_KEY}&version={%VERSION}"
},
"require": {
"ffraenz/private-composer-installer": "^5.0"
}
}
}
Provide the private package dist URL inside the .env file:
PACKAGE_KEY=pleasedontusethiskey
Let Composer require the private package:
composer require "package-name/package-name:*"
WordPress plugins
WordPress plugins can be installed using the package type wordpress-plugin in conjunction with the composer/installers installer. In this example we are installing the ACF Pro plugin. Add following entry to the repositories field inside composer.json and set the desired ACF Pro version.
{
"type": "package",
"package": {
"name": "advanced-custom-fields/advanced-custom-fields-pro",
"version": "REPLACE_WITH_LATEST_ACF_VERSION",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
"url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%PLUGIN_ACF_KEY}&t={%VERSION}"
},
"require": {
"composer/installers": "^1.4",
"ffraenz/private-composer-installer": "^5.0"
}
}
}
Provide the ACF Pro key inside the .env file. To get this key, login to your ACF account and scroll down to 'Licenses & Downloads'.
PLUGIN_ACF_KEY=pleasedontusethiskey
Let Composer require ACF Pro:
composer require "advanced-custom-fields/advanced-custom-fields-pro:*"
Configuration
The configuration options listed below may be added to the root configuration in composer.json like so:
{
"name": "...",
"description": "...",
"require": {
},
"extra": {
"private-composer-installer": {
"dotenv-path": ".",
"dotenv-name": ".env"
}
}
}
dotenv-path
Dotenv file directory relative to the root package (where composer.json is located). By default dotenv files are expected to be in the root package folder or in any of the parent folders.
dotenv-name
Dotenv file name. Defaults to .env.
Dependencies
This package heavily depends on vlucas/phpdotenv to load environment variables "automagically". This may cause version conflicts if your project already depends on it. Refer to this table to set the version of private-composer-installer accordingly or consider upgrading.
vlucas/phpdotenv |
private-composer-installer |
|---|---|
^4.1, ^5.2 |
^5.0 |
^4.0 |
^4.0 |
^3.0 |
^3.0, ^2.0 |
^2.2 |
^1.0 |
Development
Install Composer dependencies:
docker-compose run --rm composer composer install
Before pushing changes to the repository run tests and check coding standards using following command:
docker-compose run --rm composer composer test
This is a project by Fränz Friederes and contributors
ffraenz/private-composer-installer 适用场景与选型建议
ffraenz/private-composer-installer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.74M 次下载、GitHub Stars 达 232, 最近一次更新时间为 2018 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「composer」 「wordpress」 「private」 「wp」 「env」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ffraenz/private-composer-installer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ffraenz/private-composer-installer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ffraenz/private-composer-installer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Simple ASCII output of array data
Plugin for YOURLS. Default tools to use in some laemmi plugins
Generate a Composer repository from installed WordPress plugins and themes.
统计信息
- 总下载量: 1.74M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 234
- 点击次数: 17
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-08