fostam/buildinfo
Composer 安装命令:
composer require fostam/buildinfo
包简介
Store and use build time information. Useful for automated builds where information like the application version needs to be retrieved at build time, e.g. from a Git tag.
README 文档
README
Store and use build time information. Useful for automated builds where information like the application version needs to be retrieved at build time, e.g. from a Git tag.
Features
- Create build information file
- Store information like version, build number, build time etc.
- Read build information in your application and easily use it
Install
The easiest way to install buildinfo is by using composer.
Library
With the BuildInfo library (buildinfo), the buildinfo parameters created with buildinfo-create can be read and used in the actual application.
$> composer require fostam/buildinfo
Creation Tool
With the creation tool (buildinfo-create), the buildinfo parameter file is created while the application is built. This package is only required during build phase, not in the final application.
$> composer require fostam/buildinfo-create
After installation, the build time tool can be called from the following location:
$> vendor/bin/buildinfo
Usage Overview
Create build info file during the build phase for bundling it into the release (using buildinfo-create):
buildinfo create buildinfo.php --set-version 2.1.0 --set-commit d921970aadf03b3cf0e71becdaab3147ba71cdef
Reading build info file from the application (using buildinfo):
$buildInfo = BuildInfo::fromFile('buildinfo.php');
echo "my application version: " . $buildInfo->getVersion();
Build Info Creation
To create a build info file, pass the desired filename to the tool along with the build information you want to store.
The file location is relative to the current working directory, unless you give an absolute path.
Buildinfo File Types
Currently, two file types are supported, PHP and JSON. PHP is faster to read and cachable, whereas JSON is useful if the build info needs to be processed from outside PHP, too (e.g. JavaScript).
The file type is specified by the file extension. As you can give multiple build info targets, you can let both a PHP and JSON file be created.
Example:
buildinfo create dist/buildinfo.php dist/buildinfo.json --set-version 2.1.0
Build Info Parameters
There are a couple of predefined build information parameters:
--set-name my-application-name
--set-time 2019-07-23T15:34:12Z
--set-version 2.1.0
--set-build-number 3541
--set-branch master
--set-commit d921970aadf03b3cf0e71becdaab3147ba71cdef
NOTE: if the time parameter is omitted, it is automatically set to a string of the current time in the RFC 3339 format.
Additionally, arbitrary custom parameters can be given using the --set option:
--set author=john.doe@example.com
--set "comment=this is the final release"
Build Information Usage
The predefined build info parameters can be retrieved with the following methods:
use Fostam\Buildinfo;
$buildInfo = BuildInfo::fromFile('buildinfo.json');
echo $buildInfo->getName();
echo $buildInfo->getTime();
echo $buildInfo->getVersion();
echo $buildInfo->getBuildNumber();
echo $buildInfo->getBranch();
echo $buildInfo->getCommit();
The custom parameters can be retrieved with a generic get() method:
echo $buildInfo->get('author');
echo $buildInfo->get('comment');
For convenience, the build time can be also retrieved as DateTime object:
$dt = $buildInfo->getTimeAsDateTime();
echo $dt->format(DateTime::RFC3339);
fostam/buildinfo 适用场景与选型建议
fostam/buildinfo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 288 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fostam/buildinfo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fostam/buildinfo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 288
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-10-04