PHPackages                             rafaelmilanibarbosa/elastic-apm - 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. rafaelmilanibarbosa/elastic-apm

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

rafaelmilanibarbosa/elastic-apm
===============================

A package to integrate Elastic APM into Laravel

0.0.1(6y ago)03MITPHPPHP &gt;= 7.0CI failing

Since Mar 14Pushed 6y agoCompare

[ Source](https://github.com/rafaelmilanibarbosa/elastic-apm)[ Packagist](https://packagist.org/packages/rafaelmilanibarbosa/elastic-apm)[ RSS](/packages/rafaelmilanibarbosa-elastic-apm/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

PHP Elastic APM for Laravel &amp; Lumen
=======================================

[](#php-elastic-apm-for-laravel--lumen)

Laravel package of the  library, automatically handling transactions and errors/exceptions. If using `Illuminate\Support\Facades\Auth` the user Id added to the context. Tested with Laravel `5.6.*` and the philkra/elastic-apm-php-agent version `6.2.*`.

Install
-------

[](#install)

```
composer require rafaelmilanibarbosa/elastic-apm

```

Middleware
----------

[](#middleware)

### Laravel

[](#laravel)

Register as (e.g.) global middleware to be called with every request.

Register the middleware in `app/Http/Kernel.php`

```
protected $middleware = [
    // ... more middleware
    \RafaelMilaniBarbosa\ElasticApm\Middleware\RecordTransaction::class,
];
```

### Lumen

[](#lumen)

In `bootstrap/app.php` register `RafaelMilaniBarbosa\ElasticApm\Middleware\RecordTransaction::class` as middleware:

```
$app->middleware([
    RafaelMilaniBarbosa\ElasticApm\Middleware\RecordTransaction::class
]);
```

Error/Exception Handling
------------------------

[](#errorexception-handling)

### Laravel

[](#laravel-1)

In `app/Exceptions/Handler`, add the following to the `report` method:

```
ElasticApm::captureThrowable($exception);
ElasticApm::send();
```

Make sure to import the facade at the top of your file:

```
use ElasticApm;
```

### Lumen

[](#lumen-1)

not tested yet.

Agent Configuration
-------------------

[](#agent-configuration)

### Laravel

[](#laravel-2)

The following environment variables are supported in the default configuration:

VariableDescriptionAPM\_ACTIVE`true` or `false` defaults to `true`. If `false`, the agent will collect, but not send, transaction data.APM\_APPNAMEName of the app as it will appear in APM.APM\_APPVERSIONVersion of the app as it will appear in APM.APM\_SERVERURLURL to the APM intake service.APM\_SECRETTOKENSecret token, if required.APM\_APIVERSIONAPM API version, defaults to `v1` (only v1 is supported at this time).APM\_USEROUTEURI`true` or `false` defaults to `false`. The default behavior is to record the URL as sent in the request. This can result in excessive unique entries in APM. Set to `true` to have the agent use the route URL instead.APM\_QUERYLOG`true` or `false` defaults to 'true'. Set to `false` to completely disable query logging, or to `auto` if you would like to use the threshold feature.APM\_THRESHOLDQuery threshold in milliseconds, defaults to `200`. If a query takes longer then 200ms, we enable the query log. Make sure you set `APM_QUERYLOG=auto`.You may also publish the `elastic-apm.php` configuration file to change additional settings:

```
php artisan vendor:publish --tag=config
```

Once published, open the `config/elastic-apm.php` file and review the various settings.

### Laravel Test Setup

[](#laravel-test-setup)

Laravel provides classes to support running unit and feature tests with PHPUnit. In most cases, you will want to explicitly disable APM during testing since it is enabled by default. Refer to the Laravel documentation for more information ().

Because the APM agent checks it's active status using a strict boolean type, you must ensure your `APM_ACTIVE` value is a boolean `false` rather than simply a falsy value. The best way to accomplish this is to create an `.env.testing` file and include `APM_ACTIVE=false`, along with any other environment settings required for your tests. This file should be safe to include in your SCM.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

2251d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39e9473ce7c859f4da9554cfb755d3266b02d7a28f39a0a87b74a4247f42f489?d=identicon)[rafaelmilanibarbosa](/maintainers/rafaelmilanibarbosa)

---

Top Contributors

[![philkra](https://avatars.githubusercontent.com/u/35487337?v=4)](https://github.com/philkra "philkra (19 commits)")[![georgeboot](https://avatars.githubusercontent.com/u/884482?v=4)](https://github.com/georgeboot "georgeboot (18 commits)")[![tepeds](https://avatars.githubusercontent.com/u/162032891?v=4)](https://github.com/tepeds "tepeds (12 commits)")[![mpetrunic](https://avatars.githubusercontent.com/u/8836210?v=4)](https://github.com/mpetrunic "mpetrunic (5 commits)")[![petermein](https://avatars.githubusercontent.com/u/311652?v=4)](https://github.com/petermein "petermein (3 commits)")[![jcalonso](https://avatars.githubusercontent.com/u/664474?v=4)](https://github.com/jcalonso "jcalonso (2 commits)")[![jblotus](https://avatars.githubusercontent.com/u/382230?v=4)](https://github.com/jblotus "jblotus (2 commits)")[![thinkspill](https://avatars.githubusercontent.com/u/822133?v=4)](https://github.com/thinkspill "thinkspill (1 commits)")[![JustSteveKing](https://avatars.githubusercontent.com/u/6368379?v=4)](https://github.com/JustSteveKing "JustSteveKing (1 commits)")[![rafavinnce](https://avatars.githubusercontent.com/u/5910914?v=4)](https://github.com/rafavinnce "rafavinnce (1 commits)")[![dstepe](https://avatars.githubusercontent.com/u/2804725?v=4)](https://github.com/dstepe "dstepe (1 commits)")

---

Tags

laravelmonitoringdebuglumenapmelastic

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rafaelmilanibarbosa-elastic-apm/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[arkaitzgarro/elastic-apm-laravel

Laravel APM agent for Elastic v2 intake API

84433.6k](/packages/arkaitzgarro-elastic-apm-laravel)[scoutapp/scout-apm-laravel

Scout Application Performance Monitoring Agent - https://scoutapm.com

23831.3k](/packages/scoutapp-scout-apm-laravel)

PHPackages © 2026

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