PHPackages                             hotrush/elastic-apm-php-agent - 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. hotrush/elastic-apm-php-agent

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

hotrush/elastic-apm-php-agent
=============================

0.4.1(6y ago)015.3k1MITPHPPHP &gt;= 7.0

Since Feb 2Pushed 6y ago1 watchersCompare

[ Source](https://github.com/hotrush/elastic-apm-php-agent)[ Packagist](https://packagist.org/packages/hotrush/elastic-apm-php-agent)[ RSS](/packages/hotrush-elastic-apm-php-agent/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

Elastic APM: PHP Agent
======================

[](#elastic-apm-php-agent)

[![Build Status](https://camo.githubusercontent.com/83c9ffd1f4d8f41caf46cb5b6f480a39a67575c524b36686088063a025da4962/68747470733a2f2f7472617669732d63692e6f72672f686f74727573682f656c61737469632d61706d2d7068702d6167656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hotrush/elastic-apm-php-agent)

This is a PHP agent for Elastic.co's APM product: . Please note that this agent is still **experimental** and not ready for any production usage.

**Note:** This is fork. Original package repository - [philkra/elastic-apm-php-agent](https://github.com/philkra/elastic-apm-php-agent)

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

[](#installation)

The recommended way to install the agent is through [Composer](http://getcomposer.org).

Run the following composer command

```
php composer.phar require hotrush/elastic-apm-php-agent
```

After installing, you need to require Composer's autoloader:

```
require 'vendor/autoload.php';
```

Usage
-----

[](#usage)

### Initialize the Agent with minimal Config

[](#initialize-the-agent-with-minimal-config)

```
$agent = new \Hotrush\Agent(['appName' => 'demo']);
```

When creating the agent, you can directly inject shared contexts registry. Contexts registry contains info about user, request, tags and custom.

```
$contexts = new \Hotrush\Context\ContextsRegistry();
$contexts->getUser()
    ->setId(123)
    ->setUsername('User')
    ->setEmail('email@domain.com');
$contexts->getTags()->addTag('tag_name', 'tag_value');
$contexts->getRequest()->setRequestData(['body' => ['foo' => 'bar']]);
$contexts->getCustom()->addCustom('custom_key', [
    'id' => 1,
    'name' => 'Hello',
]);
$agent = new \Hotrush\Agent([ 'appName' => 'with-custom-context' ], $contexts);
```

### Capture Errors and Exceptions

[](#capture-errors-and-exceptions)

The agent can capture all types or errors and exceptions that are implemented from the interface `Throwable` ().

```
$agent->captureThrowable( new Exception() );
```

### Transaction without minimal Meta data and Context

[](#transaction-without-minimal-meta-data-and-context)

```
$trxName = 'Demo Simple Transaction';
$agent->startTransaction($trxName);
// Do some stuff you want to watch ...
$agent->stopTransaction($trxName);
```

### Transaction with Meta data and Contexts

[](#transaction-with-meta-data-and-contexts)

```
$trxName = 'Demo Transaction with more Data';
$agent->startTransaction($trxName);
// Do some stuff you want to watch ...
$agent->stopTransaction($trxName, [
    'result' => '200',
    'type'   => 'demo'
]);
$agent->getTransaction($trxName)->getContextsRegistry()->getUser()->setId(123);
$agent->getTransaction($trxName)->getContextsRegistry()->getTags()->addTag('tag', 'value');
$agent->getTransaction($trxName)->getContextsRegistry()->getTags()->setTags( [ 'k1' => 'v1', 'k2' => 'v2' ] );
```

Tests
-----

[](#tests)

```
vendor/bin/phpunit
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76% 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 ~58 days

Recently: every ~82 days

Total

12

Last Release

2424d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3cfcee390045ec2c0820506544a6778f93fed658e5e1124d38db4524aa6b3f4f?d=identicon)[hotrush](/maintainers/hotrush)

---

Top Contributors

[![hotrush](https://avatars.githubusercontent.com/u/1247004?v=4)](https://github.com/hotrush "hotrush (19 commits)")[![thinkspill](https://avatars.githubusercontent.com/u/822133?v=4)](https://github.com/thinkspill "thinkspill (4 commits)")[![philkra](https://avatars.githubusercontent.com/u/35487337?v=4)](https://github.com/philkra "philkra (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hotrush-elastic-apm-php-agent/health.svg)

```
[![Health](https://phpackages.com/badges/hotrush-elastic-apm-php-agent/health.svg)](https://phpackages.com/packages/hotrush-elastic-apm-php-agent)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[spatie/flare-client-php

Send PHP errors to Flare

177156.9M21](/packages/spatie-flare-client-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M396](/packages/drupal-core-recommended)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)

PHPackages © 2026

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