PHPackages                             edisonlabs/metrics - 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. edisonlabs/metrics

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

edisonlabs/metrics
==================

PHP library for collecting metrics.

1.x-dev(7y ago)2465[1 PRs](https://github.com/EdisonLabs/metrics/pulls)GPL-2.0+PHP

Since Jul 18Pushed 7y ago6 watchersCompare

[ Source](https://github.com/EdisonLabs/metrics)[ Packagist](https://packagist.org/packages/edisonlabs/metrics)[ RSS](/packages/edisonlabs-metrics/feed)WikiDiscussions 1.x Synced yesterday

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

[![Build Status](https://camo.githubusercontent.com/1e90a9942aefc6a91e7e9c5b41f470099658fa0e9cb801eb9ddc612f53c7640b/68747470733a2f2f7472617669732d63692e636f6d2f456469736f6e4c6162732f6d6574726963732e7376673f6272616e63683d312e78)](https://travis-ci.com/EdisonLabs/metrics)[![Coverage Status](https://camo.githubusercontent.com/ba09d3cd48966a51bc18e6f852d39a08e5d43528ed6b2112eab90c842cf7d972/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f456469736f6e4c6162732f6d6574726963732f62616467652e737667)](https://coveralls.io/github/EdisonLabs/metrics)

Metrics Collector
=================

[](#metrics-collector)

Overview
--------

[](#overview)

The Metrics Collector is a simple library that provides base classes to easily extend and collect custom metrics.

Usage
-----

[](#usage)

This library does not provide any metrics by default. To create new metrics, [create a Composer package](https://getcomposer.org/doc/01-basic-usage.md) and then add a dependency to this package:

```
composer require edisonlabs/metrics

```

Now create the metrics classes extending `edisonlabs/metrics` classes.

Example: Number of PHP files.

```
// src/EdisonLabs/Metric/NumberOfPhpFiles.php

namespace EdisonLabs\Metric;

use EdisonLabs\Metrics\Metric\AbstractMetricBase;

class NumberOfPhpFiles extends AbstractMetricBase
{
    public function getName()
    {
        return 'Number of PHP files';
    }

    public function getDescription()
    {
        return 'The total number of PHP files';
    }

    public function getMetric()
    {
        // Put the logic to calculate the total of PHP files here.
        // ..

        // Random example.
        return rand(10, 50);
    }
}
```

Configure the autoload in `composer.json`:

```
"autoload": {
    "psr-4": {
        "EdisonLabs\\Metric\\": "src/EdisonLabs/Metric"
    }
}
```

Re-create the Composer autoloader:

```
composer dump-autoload

```

Collecting metrics
------------------

[](#collecting-metrics)

There are two ways to collect the metrics: programmatically and by command-line.

#### Programmatically

[](#programmatically)

```
// collector.php

use EdisonLabs\Metrics\Collector;

$date = strtotime('now');
$config = array();

$collector = new Collector($date, $config);
$metrics = $collector->getMetrics();
```

#### Command

[](#command)

The command is located at `vendor/bin/metrics`. Include the `vendor/bin` directory in the system `$PATH` to run this command from anywhere.

Type `metrics --help` to see all the available options.

Saving metrics
--------------

[](#saving-metrics)

Create datastore classes to save your metrics:

```
// src/EdisonLabs/Metric/Datastore/SqLite.php

namespace EdisonLabs\Metric\Datastore;

use EdisonLabs\Metrics\Metric\Datastore\AbstractMetricDatastore;

class SqLite extends AbstractMetricDatastore
{
    public function getName()
    {
        return 'SQLite';
    }

    public function getDescription()
    {
        return 'Stores metrics to SQLite';
    }

    public function save()
    {
        $metrics = $this->getMetrics();

        // Put your logic to store the metrics to SQLite here.
        return true;
    }
}
```

#### Programmatically

[](#programmatically-1)

```
// datastore.php

use EdisonLabs\Metrics\Collector;
use EdisonLabs\Metrics\DatastoreHandler;

$date = strtotime('now');
$config = array();

$collector = new Collector($date, $config);
$metrics = $collector->getMetrics();

$datastoreHandler = new DatastoreHandler($date, $config);
$datastore = $datastoreHandler->getDatastoreByName('SQLite');
$datastore->setMetrics($metrics);
$datastore->save();
```

#### Command

[](#command-1)

Use the option `--save` to list and save your metrics.

```
metrics --save=SQLite

```

The `--save` option accepts multiple values.

```
metrics --save=SQLite,MySql,MyCustomDatastore

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.1% 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 ~123 days

Total

3

Last Release

2609d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82291593cc1356f74a314304499ad8aa14c24ca61f99e6be72d24e21844457ab?d=identicon)[jkribeiro](/maintainers/jkribeiro)

---

Top Contributors

[![jkribeiro](https://avatars.githubusercontent.com/u/1932061?v=4)](https://github.com/jkribeiro "jkribeiro (32 commits)")[![manuee](https://avatars.githubusercontent.com/u/105582?v=4)](https://github.com/manuee "manuee (5 commits)")[![douggreen](https://avatars.githubusercontent.com/u/1244341?v=4)](https://github.com/douggreen "douggreen (1 commits)")[![kmoll](https://avatars.githubusercontent.com/u/4575507?v=4)](https://github.com/kmoll "kmoll (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/edisonlabs-metrics/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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