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.4.0(1mo ago)6479.0k↓33.3%4[1 PRs](https://github.com/previousnext/php-prometheus/pulls)GPL-2.0-or-laterPHPPHP ^8.2CI passing

Since Oct 4Pushed 1mo ago5 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 3d ago

READMEChangelog (1)Dependencies (12)Versions (12)Used By (0)

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

[](#php-prometheus-serializer)

A PHP library for serializing to the prometheus text format.

**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

62

—

FairBetter than 99% of packages

Maintenance91

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

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

Recently: every ~490 days

Total

8

Last Release

43d ago

PHP version history (6 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

1.4.0PHP ^8.2

### 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 (21 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### 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

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M339](/packages/api-platform-core)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[api-platform/symfony

Symfony API Platform integration

384.5M129](/packages/api-platform-symfony)[api-platform/serializer

API Platform core Serializer

274.8M87](/packages/api-platform-serializer)[api-platform/openapi

Models to build and serialize an OpenAPI specification.

404.8M94](/packages/api-platform-openapi)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

12310.5M135](/packages/web-auth-webauthn-lib)

PHPackages © 2026

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