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

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

speakol-ads/elastic-apm-laravel
===============================

A package to integrate Elastic APM into Laravel

v7.1.2(6y ago)01.3kMITPHPPHP &gt;= 7.0

Since Jun 19Pushed 6y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (7)Versions (19)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.8.*` and the philkra/elastic-apm-php-agent version `7.*`.

Install
-------

[](#install)

```
composer require speakol-ads/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
    \PhilKra\ElasticApmLaravel\Middleware\RecordTransaction::class,
];
```

### Lumen

[](#lumen)

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

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

Spans
-----

[](#spans)

### Laravel

[](#laravel-1)

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(\PhilKra\ElasticApmLaravel\Apm\Transaction::class);

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

// do some stuff

$span->end();
```

### Lumen

[](#lumen-1)

pending

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

[](#errorexception-handling)

### Laravel

[](#laravel-2)

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

```
\ElasticApm::captureThrowable($exception, [], request()->__apm__());
```

### Lumen

[](#lumen-2)

not tested yet.

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

[](#agent-configuration)

### Laravel

[](#laravel-3)

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.APM\_CONNECTION\_TIMEOUTDefaults to `10000` millisecond.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

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor3

3 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 ~30 days

Total

14

Last Release

2486d ago

Major Versions

5.8.1 → v7.12019-07-21

### Community

Maintainers

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

---

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 (16 commits)")[![alash3al](https://avatars.githubusercontent.com/u/3078292?v=4)](https://github.com/alash3al "alash3al (8 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)")[![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)")[![montross50](https://avatars.githubusercontent.com/u/62939?v=4)](https://github.com/montross50 "montross50 (1 commits)")

---

Tags

laravelmonitoringdebuglumenapmelastic

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/speakol-ads-elastic-apm-laravel/health.svg)](https://phpackages.com/packages/speakol-ads-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)
