PHPackages                             iskander-g/laravel-new-relic - 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. iskander-g/laravel-new-relic

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

iskander-g/laravel-new-relic
============================

Monitor your Laravel application performance with New Relic

v1.0.2(3y ago)02.1k↓33.3%MITPHPPHP ^8.1CI passing

Since May 21Pushed 3mo agoCompare

[ Source](https://github.com/iskander-g/laravel-new-relic)[ Packagist](https://packagist.org/packages/iskander-g/laravel-new-relic)[ Docs](https://github.com/JackWH/laravel-new-relic)[ RSS](/packages/iskander-g-laravel-new-relic/feed)WikiDiscussions main Synced 1mo ago

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

Laravel New Relic
=================

[](#laravel-new-relic)

[![Latest Version on Packagist](https://camo.githubusercontent.com/55178d7bb52e8bb5f5f915c5ee215f9f7bbf9ceee66c798d830fbe30018c3c19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61636b77682f6c61726176656c2d6e65772d72656c69632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jackwh/laravel-new-relic)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8d7e1d75b0d4442b2f58a00b062dc77e56b938248ce74fe15793d38176d0cd6e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a61636b77682f6c61726176656c2d6e65772d72656c69632f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/jackwh/laravel-new-relic/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/db5367733afd2572c413ce4a11be38152fb703225ef36c274102e3d25782a080/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a61636b77682f6c61726176656c2d6e65772d72656c69632f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/jackwh/laravel-new-relic/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b3f79a477f372e65d2efcc770145b117157c722e3185fab14fd2ae481f1c9838/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a61636b77682f6c61726176656c2d6e65772d72656c69632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jackwh/laravel-new-relic)

[![](https://camo.githubusercontent.com/2739e626a466d9296ef03d4760d467885d1ede361f2b53992349ca6e57ca84f1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4e657725323052656c6963253230666f722532304c61726176656c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6a61636b77682532466c61726176656c2d6e65772d72656c6963267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d4e65772b52656c69632b706572666f726d616e63652b6d6f6e69746f72696e672532432b6f7074696d697365642b666f722b4c61726176656c2b6170706c69636174696f6e732e266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313235707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/2739e626a466d9296ef03d4760d467885d1ede361f2b53992349ca6e57ca84f1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4e657725323052656c6963253230666f722532304c61726176656c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6a61636b77682532466c61726176656c2d6e65772d72656c6963267061747465726e3d63697263756974426f617264267374796c653d7374796c655f31266465736372697074696f6e3d4e65772b52656c69632b706572666f726d616e63652b6d6f6e69746f72696e672532432b6f7074696d697365642b666f722b4c61726176656c2b6170706c69636174696f6e732e266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313235707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

This package makes it simple to set up and monitor your [Laravel](https://laravel.com) application with [New Relic APM](https://newrelic.com/products/application-monitoring).

New Relic provides some excellent low-level insights into your application. The [New Relic PHP agent](https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/introduction-new-relic-php/) is particularly useful in production environments, as it hooks in at a lower level than other monitoring services, and with little to no impact on performance.

> **New Relic has a fully-featured [free plan](https://newrelic.com/pricing)** which is ideal for growing Laravel applications. This package isn't affiliated with them — I just built it because I've found the service very helpful whilst scaling my app, and wanted a more tailored solution for Laravel.
>
> Whilst New Relic can monitor a Laravel application out-of-the-box, this package reports transactions that are optimised for Laravel, and reported in a more consisted way.

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

[](#installation)

To monitor your application in production you'll need a [New Relic](https://newrelic.com) API account, and you should [install the PHP monitoring agent](https://docs.newrelic.com/docs/apm/agents/php-agent/installation/php-agent-installation-overview/). You don't need to install New Relic in your development environment (unless you really want to). If the extension isn't detected the package will simulate calls to the New Relic PHP agent, and log each one so you can test before deploying.

> If you're installing this on a server which is *already* being monitored by New Relic, **be aware this package reports transactions with different naming conventions than New Relic normally auto-detects**. If your existing New Relic data is very important to you, don't install this.

To install the package, add it to your Laravel project with Composer:

```
composer require jackwh/laravel-new-relic
```

Then publish the config file:

```
php artisan vendor:publish --provider="JackWH\LaravelNewRelic\LaravelNewRelicServiceProvider"
```

> **That's it, you're done! The package is ready to go, and configured out-of-the-box.**

How It Works
------------

[](#how-it-works)

#### The Service Provider

[](#the-service-provider)

Laravel will auto-discover the `LaravelNewRelicServiceProvider` class, which binds `NewRelicTransactionHandler` and `NewRelicTransaction` classes as [scoped singletons](https://laravel.com/docs/9.x/container#binding-scoped) to the service container.

New Relic's transaction API only allows a single transaction to be active at a time. That's why the classes are loaded as singletons. Generally speaking, don't try to start a new transaction mid-way through the request lifecycle.

#### Loggable Environments

[](#loggable-environments)

The package checks if New Relic is installed. If it's not found, you can log simulated transactions.

In a loggable environment, the package will simulate calls it would normally make to New Relic's methods (e.g. `newrelic_start_transaction()`). These are loaded from the `LoggableNewRelicFunctions.php` helper file. You can check your logs to see what's happening under the hood.

Don't worry if your logs don't show a "transaction ended" item, as New Relic automatically finishes them at the end of a request. This is only really important for long-running processes, like the queue handler.

> Once you're happy logging is working as expected, you can comment out `local` in the `config/new-relic.php` file. This is just intended to help you check the package is working before initial deployment, or when making changes which would affect New Relic transactions.

#### Live Environments

[](#live-environments)

Assuming the New Relic extension is loaded, the package sets up hooks into Laravel to monitor requests at different stages of the lifecycle:

- **HTTP transactions** are handled with a global `NewRelicMiddleware` on each request
- **CLI requests** are filtered out for noise (so long-running calls like `php artisan horizon` won't skew your stats).
- **Queued jobs** record a transaction automatically as each one starts and ends.
- **Artisan commands** are recorded as individual transactions.
- **Scheduled tasks** are monitored as each one is executed.

The package also registers a `php artisan new-relic:deploy` command, to notify New Relic of changes as part of your deployment process.

Configuration
-------------

[](#configuration)

The [configuration file](config/new-relic.php) is documented in detail — read through each comment to understand how it will affect transaction reporting. A few settings worth pointing out here are below:

#### HTTP Requests

[](#http-requests)

```
'http'         => [
    'middleware' => \JackWH\LaravelNewRelic\Middleware\NewRelicMiddleware::class,

    // ...

    'rewrite' => [
        '/livewire/livewire.js'     => 'livewire.js',
        '/livewire/livewire.js.map' => 'livewire.js.map',
    ],

    // ...

    'ignore' => [
        'debugbar.**',
        'horizon.**',
        'telescope.**',
    ],
],
```

The built-in `NewRelicMiddleware` class should be fine for most use cases, but you can extend it with your own implementation if needed.

The `rewrite` key is useful for routes which don't have names defined (often the case with packages that expose public resources, like Livewire). You can rewrite their names for consistency here.

We've set some sensible `ignore` rules by default, feel free to adjust as required.

#### Queue Handling

[](#queue-handling)

```
'queue'        => [
    'ignore' => [
        'connections' => ['sync'],
        'queues'      => [],
        'jobs'        => [],
    ],
],
```

By default the `sync` connection will be ignored. This means a new job starting on this queue won't interrupt the existing transaction that started at the beginning of the request. You can also filter out specific queues and jobs, too.

Deployments
-----------

[](#deployments)

After each new deployment, you should notify New Relic so they can report on metric variances across multiple releases. The package includes a command to do this:

```
php artisan new-relic:deploy [description] [revision]
```

If you don't provide a git revision hash, the package can attempt to auto-detect it by calling `git log --pretty="%H" -n1 HEAD`

---

### To-Do

[](#to-do)

1. Improve the loggable transactions, make it clearer that HTTP transactions will end automatically
2. Add some tests
3. Hopefully someone can confirm if this works with Octane?

### Contributing

[](#contributing)

All contributions are welcome! And if you found this useful, I'd love to know.

### Credits

[](#credits)

- [Jack Webb-Heller](https://github.com/JackWH)
- [All Contributors](../../contributors)

### License

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance54

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

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

Total

3

Last Release

1439d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c53422add2ba35d85da6698df0f4ec8e668ec9e4ddefaca2931d5d4f6cfc3d1c?d=identicon)[iskander-g](/maintainers/iskander-g)

---

Top Contributors

[![jackwh](https://avatars.githubusercontent.com/u/627533?v=4)](https://github.com/jackwh "jackwh (20 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![fruitl00p](https://avatars.githubusercontent.com/u/1492861?v=4)](https://github.com/fruitl00p "fruitl00p (4 commits)")[![iskander-g](https://avatars.githubusercontent.com/u/4549657?v=4)](https://github.com/iskander-g "iskander-g (4 commits)")[![rbiya](https://avatars.githubusercontent.com/u/107550932?v=4)](https://github.com/rbiya "rbiya (1 commits)")[![ksimenic](https://avatars.githubusercontent.com/u/12883124?v=4)](https://github.com/ksimenic "ksimenic (1 commits)")[![crishoj](https://avatars.githubusercontent.com/u/20393?v=4)](https://github.com/crishoj "crishoj (1 commits)")

---

Tags

laravelmonitoringperformancenew relicJackWHlaravel-new-relic

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/iskander-g-laravel-new-relic/health.svg)

```
[![Health](https://phpackages.com/badges/iskander-g-laravel-new-relic/health.svg)](https://phpackages.com/packages/iskander-g-laravel-new-relic)
```

###  Alternatives

[jackwh/laravel-new-relic

Monitor your Laravel application performance with New Relic

112827.2k](/packages/jackwh-laravel-new-relic)[inspector-apm/inspector-laravel

Code Execution Monitoring, built for developers.

2332.0M2](/packages/inspector-apm-inspector-laravel)[scoutapp/scout-apm-laravel

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

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

An easy to use application performance monitor.

14413.1k](/packages/tobiasdierich-gauge)

PHPackages © 2026

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