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

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

zuams/elastic-apm-laravel
=========================

A package to integrate Elastic APM into Laravel

v1.0.0(6y ago)06MITPHPPHP &gt;= 5.0.0

Since Oct 23Pushed 6y agoCompare

[ Source](https://github.com/zuams/elastic-apm-laravel)[ Packagist](https://packagist.org/packages/zuams/elastic-apm-laravel)[ RSS](/packages/zuams-elastic-apm-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

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

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

Forked from [Zuams/elastic-apm-laravel](https://github.com/Zuams/elastic-apm-laravel) for adding support for PHP &gt;= 5.6

Install
-------

[](#install)

```
composer require zuams/elastic-apm-laravel

```

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
    \Zuams\ElasticApmLaravel\Middleware\RecordTransaction::class,
];
```

### Lumen

[](#lumen)

In `bootstrap/app.php` register `Zuams\ElasticApmLaravel\Middleware\RecordTransaction::class` as middleware:

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

Service Provider
----------------

[](#service-provider)

### Laravel

[](#laravel-1)

No need to register service provider manually. It is registered automatically by [package discovery](https://laravel.com/docs/5.6/packages#package-discovery).

### Lumen

[](#lumen-1)

In `bootstrap/app.php` register `\Zuams\ElasticApmLaravel\Providers\ElasticApmServiceProvider::class` as service provider:

```
$app->register(\Zuams\ElasticApmLaravel\Providers\ElasticApmServiceProvider::class);
```

Spans
-----

[](#spans)

### Laravel

[](#laravel-2)

A Transaction object is made available via the dependency container and can be used to start a new span at any point in the application. The Span will automatically add itself to the Transaction when it is ended.

```
// Use any normal Laravel method of resolving the dependency
$transaction = app(\Zuams\ElasticApmLaravel\Apm\Transaction::class);

$span = $transaction->startNewSpan('My Span', 'app.component_name');

// do some stuff

$span->end();
```

### Lumen

[](#lumen-2)

pending

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

[](#errorexception-handling)

### Laravel

[](#laravel-3)

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-3)

not tested yet.

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

[](#agent-configuration)

### Laravel

[](#laravel-4)

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`.APM\_BACKTRACEDEPTHDefaults to `25`. Depth of backtrace in query span.APM\_RENDERSOURCEDefaults to `true`. Include source code in query span.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

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity54

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

Every ~0 days

Total

2

Last Release

2393d ago

Major Versions

v0.0.1 → v1.0.02019-10-23

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

v1.0.0PHP &gt;= 5.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/12622765edc976974af147572241e9c53fa52e435358b9ca85b817db61542900?d=identicon)[zuams](/maintainers/zuams)

---

Top Contributors

[![philkra](https://avatars.githubusercontent.com/u/35487337?v=4)](https://github.com/philkra "philkra (24 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 (16 commits)")[![mpetrunic](https://avatars.githubusercontent.com/u/8836210?v=4)](https://github.com/mpetrunic "mpetrunic (5 commits)")[![dstepe](https://avatars.githubusercontent.com/u/2804725?v=4)](https://github.com/dstepe "dstepe (4 commits)")[![petermein](https://avatars.githubusercontent.com/u/311652?v=4)](https://github.com/petermein "petermein (3 commits)")[![jblotus](https://avatars.githubusercontent.com/u/382230?v=4)](https://github.com/jblotus "jblotus (3 commits)")[![jcalonso](https://avatars.githubusercontent.com/u/664474?v=4)](https://github.com/jcalonso "jcalonso (2 commits)")[![AlexGodbehere](https://avatars.githubusercontent.com/u/114239316?v=4)](https://github.com/AlexGodbehere "AlexGodbehere (2 commits)")[![YuZhenXie](https://avatars.githubusercontent.com/u/5066215?v=4)](https://github.com/YuZhenXie "YuZhenXie (1 commits)")[![JustSteveKing](https://avatars.githubusercontent.com/u/6368379?v=4)](https://github.com/JustSteveKing "JustSteveKing (1 commits)")[![montross50](https://avatars.githubusercontent.com/u/62939?v=4)](https://github.com/montross50 "montross50 (1 commits)")[![thinkspill](https://avatars.githubusercontent.com/u/822133?v=4)](https://github.com/thinkspill "thinkspill (1 commits)")

---

Tags

laravelmonitoringdebuglumenapmelastic

### Embed Badge

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

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

###  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)
