PHPackages                             previousnext/php-prometheus - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. previousnext/php-prometheus

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

previousnext/php-prometheus
===========================

A PHP library for serializing to the prometheus text format.

1.3.0(1y ago)6443.5k↑10.1%4[2 PRs](https://github.com/previousnext/php-prometheus/pulls)GPL-2.0-or-laterPHPPHP ^8.1

Since Oct 4Pushed 1y ago6 watchersCompare

[ Source](https://github.com/previousnext/php-prometheus)[ Packagist](https://packagist.org/packages/previousnext/php-prometheus)[ RSS](/packages/previousnext-php-prometheus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (8)Used By (0)

PHP Prometheus Serializer
=========================

[](#php-prometheus-serializer)

A PHP library for serializing to the prometheus text format.

[![CircleCI](https://camo.githubusercontent.com/b92ad3668c43ccfd382963ffeef93cfe0fad0db0a39aef02fe3655ada933cc7e/68747470733a2f2f636972636c6563692e636f6d2f67682f70726576696f75736e6578742f7068702d70726f6d6574686575732e7376673f7374796c653d737667)](https://circleci.com/gh/previousnext/php-prometheus)

**NOTE** This library does not keep state. It is intended purely as a serialization library. Therefore, there are no methods into increment or decrement values for metrics, only to set them in order to be serialized.

Installation
------------

[](#installation)

```
composer require previousnext/php-prometheus

```

Usage
-----

[](#usage)

### Gauge

[](#gauge)

```
$gauge = new Gauge("foo", "bar", "A test gauge");
$gauge->set(100, ['baz' => 'wiz']);
$gauge->set(90, ['wobble' => 'wibble', 'bing' => 'bong']);
$gauge->set(0);

$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($gauge, 'prometheus');
```

Expected output:

```
# HELP foo_bar A test gauge
# TYPE foo_bar gauge
foo_bar{baz="wiz"} 100
foo_bar{wobble="wibble",bing="bong"} 90
foo_bar 0

```

### Counter

[](#counter)

```
$counter = new Counter("foo", "bar", "A counter for testing");
$counter->set(100, ['baz' => 'wiz']);

$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($counter, 'prometheus');
```

Expected output:

```
# HELP foo_bar A counter for testing
# TYPE foo_bar counter
foo_bar{baz="wiz"} 100

```

### Summary

[](#summary)

```
$summary = new Summary("foo", "bar", "Summary help text", 'baz');
$buckets = [0, 0.25, 0.5, 0.75, 1];
$values = [2, 4, 6, 8, 10];
$summary->setValues($buckets, $values);
$summary->setSum(54321);
$summary->setCount(212);

$serializer = MetricSerializerFactory::create();
$output = $serializer->serialize($summary, 'prometheus');
```

Expected output:

```
# HELP foo_bar Summary help text
# TYPE foo_bar summary
foo_bar{baz="0"} 2
foo_bar{baz="0.25"} 4
foo_bar{baz="0.5"} 6
foo_bar{baz="0.75"} 8
foo_bar{baz="1"} 10
foo_bar_sum 54321
foo_bar_count 212

```

Developing
----------

[](#developing)

PHP CodeSniffer

```
./bin/phpcs

```

PHPUnit

```
./bin/phpunit

```

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community12

Small or concentrated contributor base

Maturity75

Established project with proven stability

 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 ~345 days

Recently: every ~371 days

Total

7

Last Release

714d ago

PHP version history (5 changes)1.0.0-alpha1PHP ^7.1

1.1.0PHP ^7.2

1.1.1PHP ^7.2||^8.0

1.2.0PHP ^8.1|^8.2

1.3.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6132?v=4)[Kim Pepper](/maintainers/kimpepper)[@kimpepper](https://github.com/kimpepper)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/previousnext-php-prometheus/health.svg)

```
[![Health](https://phpackages.com/badges/previousnext-php-prometheus/health.svg)](https://phpackages.com/packages/previousnext-php-prometheus)
```

###  Alternatives

[symfony/serializer-pack

A pack for the Symfony serializer

1.1k28.2M221](/packages/symfony-serializer-pack)[api-platform/symfony

Symfony API Platform integration

323.2M67](/packages/api-platform-symfony)[api-platform/serializer

API Platform core Serializer

223.4M31](/packages/api-platform-serializer)[ribal/onix

An ONIX 3.0 Parser

244.1k](/packages/ribal-onix)

PHPackages © 2026

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