PHPackages                             fostam/buildinfo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fostam/buildinfo

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

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.

v1.1.0(5y ago)0288[1 PRs](https://github.com/fostam/php-buildinfo/pulls)1Apache-2.0PHPPHP &gt;=7.2CI failing

Since Oct 7Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/fostam/php-buildinfo)[ Packagist](https://packagist.org/packages/fostam/buildinfo)[ RSS](/packages/fostam-buildinfo/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (1)

buildinfo
=========

[](#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.

Features
--------

[](#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
-------

[](#install)

The easiest way to install *buildinfo* is by using [composer](https://getcomposer.org/).

### Library

[](#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

[](#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
--------------

[](#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
-------------------

[](#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

[](#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

[](#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
-----------------------

[](#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);

```

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance54

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~340 days

Total

2

Last Release

2071d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c32c6b8631d5c8b6e67cd67499be6106fe0298715cf74a38554e6608e140492?d=identicon)[fostam](/maintainers/fostam)

---

Top Contributors

[![Stammido](https://avatars.githubusercontent.com/u/123233799?v=4)](https://github.com/Stammido "Stammido (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fostam-buildinfo/health.svg)

```
[![Health](https://phpackages.com/badges/fostam-buildinfo/health.svg)](https://phpackages.com/packages/fostam-buildinfo)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
