PHPackages                             erickskrauch/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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. erickskrauch/prometheus

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

erickskrauch/prometheus
=======================

Prometheus instrumentation library for PHP applications.

0.1.0(5mo ago)1642[1 issues](https://github.com/erickskrauch/prometheus-php/issues)MITPHPPHP ^8.1CI passing

Since Dec 5Pushed 5mo agoCompare

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

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

Prometheus metrics for PHP
==========================

[](#prometheus-metrics-for-php)

Prometheus metrics collector and exporter for PHP. Storage is abstracted to allow better integration with your infrastructure.

[![Latest Version on Packagist](https://camo.githubusercontent.com/066a0a61c535693a06d244f0f2b783496734c92cc100033d588090b176832ac9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f657269636b736b72617563682f70726f6d6574686575732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/erickskrauch/prometheus)[![Total Downloads](https://camo.githubusercontent.com/7c745755dad237113413e3f79419753bb722d4af2ffc1c4d562ea7924b8342e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f657269636b736b72617563682f70726f6d6574686575732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/erickskrauch/prometheus/stats)[![Software License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/72c753244aa29ad6d74b783db55454337f04794417961af2acf0346a9a5e66a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f657269636b736b72617563682f70726f6d6574686575732d7068702f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/erickskrauch/prometheus-php/actions)

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

[](#installation)

Install it as [Composer](https://getcomposer.org) dependency:

```
composer require erickskrauch/prometheus
```

Usage
-----

[](#usage)

```
use ErickSkrauch\Prometheus\CollectorRegistry;
use ErickSkrauch\Prometheus\NamespacedRegistry;
use ErickSkrauch\Prometheus\Storage\Redis;
use ErickSkrauch\Prometheus\Storage\Redis\PHPRedis;

$redisClientImplementation = PHPRedis::create(['host' => 'localhost', 'port' => 6379]);
$storage = new Redis($redisClientImplementation);
$registry = new CollectorRegistry($storage);
// Might be useful to prefix all metrics in your app
// $registry = new NamespacedRegistry('github', $registry);

$registry->counter('readme_readers_total')->inc()
$registry->gauge('stars_count', 'How many people read this code example and helped promote the project')->set(1_000);
$registry->histogram('delay_before_decision_to_install_seconds', [1, 5, 10, 20, 60] ['trafficSource'])->observe(5.78, ['google']);
```

In addition to the [PHPRedis](https://github.com/phpredis/phpredis) extension, it also offers an implementation for the [Predis](https://github.com/predis/predis) library. You can easily write your own adapter for any Redis client by implementing the `\ErickSkrauch\Prometheus\Storage\Redis\RedisClient` interface.

An in-memory storage driver is also available via `\ErickSkrauch\Prometheus\Storage\InMemory`.

To expose metrics, register a route in your framework, such as this example for Symfony:

```
use ErickSkrauch\Prometheus\RegistryInterface;
use ErickSkrauch\Prometheus\Renderer\RenderTextFormat;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class MetricsController
{
    #[Route('/metrics', name: 'prometheus_metrics')]
    public function expose(RegistryInterface $registry): Response
    {
        $renderer = new RenderTextFormat();

        return new Response(
            $renderer->render($registry->collectMetrics()),
            headers: ['Content-Type' => RenderTextFormat::MIME_TYPE],
        );
    }
}
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance71

Regular maintenance activity

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

156d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab581fb1f2be61c3492ba1913ed418abe3cf64439589aeb7d6c68f854ad39e6e?d=identicon)[ErickSkrauch](/maintainers/ErickSkrauch)

---

Top Contributors

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

---

Tags

metricsobservabilityprometheusprometheus-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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