PHPackages                             chaseisabelle/phprom-client - 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. chaseisabelle/phprom-client

ActiveLibrary

chaseisabelle/phprom-client
===========================

phprom client

v0.0.5(5y ago)02.5k1[1 PRs](https://github.com/chaseisabelle/phprom-client/pulls)1MITPHPPHP &gt;=7.1

Since Sep 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/chaseisabelle/phprom-client)[ Packagist](https://packagist.org/packages/chaseisabelle/phprom-client)[ RSS](/packages/chaseisabelle-phprom-client/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (8)Used By (1)

phprom client
=============

[](#phprom-client)

a client lib for [phprom](https://github.com/chaseisabelle/phprom), a prometheus metric datastore for php apps

---

### example

[](#example)

see a fully functional example [here](https://github.com/chaseisabelle/phprom-example)

---

### prerequisites

[](#prerequisites)

install and run the [server](https://github.com/chaseisabelle/phprom)

### install

[](#install)

- install the [client](https://packagist.org/packages/chaseisabelle/phprom-client) or [bundle](https://github.com/chaseisabelle/phprom-bundle)
    - `composer require chaseisabelle/phprom-client`
    - `composer require chaseisabelle/phprom-bundle`

#### install grpc requirements

[](#install-grpc-requirements)

- NOTE: this is only required if you are using the grpc api
- install grpc
    - `composer require 'grpc/grpc:1.30.0' 'google/protobuf:3.13.*'`
- install [grpc extension](https://grpc.io/docs/languages/php/quickstart/)
    - `pecl install grpc`
    - or use the [docker image](https://hub.docker.com/r/grpc/php)

---

### usage

[](#usage)

- [instantiate a client](#instantiate-a-client)
- [get the metrics for the prometheus scraper](#get-the-metrics-for-the-prometheus-scraper)
- [register and record metrics automagically](#register-and-record-metrics-automagically)
- [create a timer to time and record latencies](#create-a-timer-to-time-and-record-latencies)
- [register and record metrics manually](#register-and-record-metrics-manually)

#### instantiate a client

[](#instantiate-a-client)

##### grpc

[](#grpc)

```
// connect to the server using grpc
$phprom = new PHProm('127.0.0.1:3333');
// or
$phprom = new PHProm('127.0.0.1:3333', PHProm::GRPC_API);
```

##### rest/http

[](#resthttp)

```
// or connect to the server using rest/http
$phprom = new PHProm('127.0.0.1:3333', PHProm::REST_API);
```

*!NOTE!* see the suggested packages list in `composer.json`:

```
  "suggest": {
    "ext-grpc": "* required for grpc api",
    "ext-curl": "* required for rest/http api"
  }
```

##### grpc vs rest/http

[](#grpc-vs-resthttp)

both the grpc and rest/http api benchmark at about the same when running on a local network:

- min: 2ms
- max: 12ms
- avg: ~6ms

#### get the metrics for the prometheus scraper

[](#get-the-metrics-for-the-prometheus-scraper)

```
print($phprom->get());
// or...
echo $phprom->get();
```

#### register and record metrics automagically

[](#register-and-record-metrics-automagically)

##### counter

[](#counter)

```
$counter = (new Counter($phprom))
    ->setNamespace('namespace')
    ->setName('name')
    ->setDescription('description')
    ->setLabels(['label1', 'label2']); //record(
    1.2345,
    ['label1' => 'foo', 'label2' => 'bar']
);
```

##### histogram

[](#histogram)

```
$histogram = (new Histogram($phprom))
    ->setNamespace('namespace')
    ->setName('name')
    ->setDescription('description')
    ->setLabels(['label1', 'label2']) //setBuckets([0.1, 0.5, 1, 2, 5]); //record(
    1.2345,
    ['label1' => 'foo', 'label2' => 'bar']
);
```

##### summary

[](#summary)

```
$summary = (new Summary($phprom))
    ->setNamespace('namespace')
    ->setName('name')
    ->setDescription('description')
    ->setLabels(['label1', 'label2']) //setObjectives([0.1, 0.5, 1, 2, 5]) //setMaxAge(0) //setAgeBuckets(0) //setBufCap(0); //record(
    1.2345,
    ['label1' => 'foo', 'label2' => 'bar']
);
```

##### gauge

[](#gauge)

```
$gauge = (new Gauge($phprom))
    ->setNamespace('namespace')
    ->setName('name')
    ->setDescription('description')
    ->setLabels(['label1', 'label2']); //record(
    1.2345,
    ['label1' => 'foo', 'label2' => 'bar']
);
```

#### create a timer to time and record latencies

[](#create-a-timer-to-time-and-record-latencies)

```
$histogram = (new Histogram($phprom))
    ->setNamespace('namespace')
    ->setName('name')
    ->setDescription('description')
    ->setLabels(['label1', 'label2'])
    ->setBuckets(range(1, 10));

$timer = new Timer($histogram);

$timer->start();

sleep(rand(1, 10));

$timer->stop()
    ->record(['label1' => 'foo', 'label2' => 'bar'])
    ->reset();
```

#### register and record metrics manually

[](#register-and-record-metrics-manually)

##### counter

[](#counter-1)

```
$phprom->registerCounter(
    'namespace',
    'name',
    'description',
    ['label1', 'label2'] //recordCounter(
    'namespace',
    'name',
    1.2345,
    ['label1' => 'foo', 'label2' => 'bar']
);
```

##### histogram

[](#histogram-1)

```
$phprom->registerHistogram(
    'namespace',
    'name',
    'description',
    ['label1', 'label2'], // 'foo', 'label2' => 'bar']
);
```

##### summary

[](#summary-1)

```
$phprom->registerSummary(
    'namespace',
    'name',
    'description',
    ['label1', 'label2'], // 'foo', 'label2' => 'bar']
);
```

##### gauge

[](#gauge-1)

```
$phprom->registerGauge(
    'namespace',
    'name',
    'description',
    ['label1', 'label2'] //recordGauge(
    'namespace',
    'name',
    1.2345,
    ['label1' => 'foo', 'label2' => 'bar']
);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity44

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

Total

5

Last Release

2004d ago

PHP version history (2 changes)v0.0.1PHP &gt;=5.6

v0.0.5PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

metricsphpprometheusprometheusphprom

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chaseisabelle-phprom-client/health.svg)

```
[![Health](https://phpackages.com/badges/chaseisabelle-phprom-client/health.svg)](https://phpackages.com/packages/chaseisabelle-phprom-client)
```

###  Alternatives

[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)[google/grpc-gcp

gRPC GCP library for channel management

18497.8M3](/packages/google-grpc-gcp)[googleads/google-ads-php

Google Ads API client for PHP

3497.6M9](/packages/googleads-google-ads-php)[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)[artprima/prometheus-metrics-bundle

Symfony 5/6/7/8 Prometheus Metrics Bundle

1723.7M3](/packages/artprima-prometheus-metrics-bundle)[lkaemmerling/laravel-horizon-prometheus-exporter

A small package to gain and export long time information from Laravel &amp; Horizon for Prometheus.

1602.0M](/packages/lkaemmerling-laravel-horizon-prometheus-exporter)

PHPackages © 2026

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