PHPackages                             zfuming/laravel-newrelic - 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. zfuming/laravel-newrelic

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

zfuming/laravel-newrelic
========================

Laravel 5 NewRelic Integration

2.2.2(7y ago)090MITPHPPHP &gt;=5.5.0

Since Apr 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/zfuming/laravel-newrelic)[ Packagist](https://packagist.org/packages/zfuming/laravel-newrelic)[ Docs](https://github.com/In-Touch/laravel-newrelic)[ RSS](/packages/zfuming-laravel-newrelic/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (2)Versions (23)Used By (0)

Laravel 5 NewRelic Service Provider
===================================

[](#laravel-5-newrelic-service-provider)

Laravel VersionPackage TagSupported5.4.x2.2.xyes5.2.x2.1.xyes5.1.x2.0.xyes5.0.x2.0.xno*[see below for Laravel 4.x support](https://github.com/In-Touch/laravel-newrelic#laravel-4x-support)*

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

[](#installation)

See the table above for package version information, and change the version below accordingly.

Using `composer`, run:

```
composer require intouch/laravel-newrelic:"~2.0"

```

Or add `intouch/laravel-newrelic` to your composer requirements:

```
"require": {
    "intouch/laravel-newrelic": "~2.0"
}

```

... and then run `composer install`

Once the package is installed, open your `config/app.php` configuration file and locate the `providers` key. Add the following line to the end:

```
Intouch\LaravelNewrelic\NewrelicServiceProvider::class,
```

Optionally, locate the `aliases` key and add the following line:

```
'Newrelic' => Intouch\LaravelNewrelic\Facades\Newrelic::class,
```

Finally, publish the default configuration (it will end up in `config/newrelic.php`):

```
php artisan vendor:publish --provider="Intouch\LaravelNewrelic\NewrelicServiceProvider"

```

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

[](#configuration)

Once the configuration from the package if published, see `config/newrelic.php` for configuration options and descriptions.

Transaction Names
-----------------

[](#transaction-names)

Naming is done by replacing tokens in a `name_provider` string with formatted output collected from the application. The `newrelic.name_provider` config parameter holds this string - note that non-token string parts are left as-is.

TokenDescriptionExample{controller}Controller / Action nameApp\\Http\\Controllers\\MyController@action{method}HTTP VerbGET, POST{route}Route Name if named, otherwise {controller}auth.login{path}Registered route path/users/{id?}{uri}Request URI path/users/12345The default `newrelic.name_provider` string is `'{uri} {route}'`.

Eloquent Model Observers
------------------------

[](#eloquent-model-observers)

There are two observer classes for monitoring your Eloquent models, the `NewrelicCountingObserver` and the `NewrelicTimingObserver`. As their names suggest, one counts the number of times observable model events happen and the other gathers their timings (in milliseconds). These recorded metrics will show up in your NewRelic Custom Metrics.

The `NewrelicCountingObserver` can be used for any observable model events, including your custom events. The `NewrelicTimingObserver` currently only supports the built-in Eloquent observable events (see [Model Events](https://laravel.com/docs/5.1/eloquent#events) in the Laravel documentation).

Using the observers is simple - wherever you choose to register your model observers, simply add:

```
User::observe(new \Intouch\LaravelNewrelic\Observers\NewrelicTimingObserver() );
User::observe(new \Intouch\LaravelNewrelic\Observers\NewrelicCountingObserver() );
```

... assuming you want to observe the `User` model.

Both observers take two optional parameters to their constructors: `$name` and `$care`. `$name` is the name you want to give to your custom metric, and if unset will default to the class name of the model object it is observing. If you want to change the `$care` array without changing the naming, simply pass `null` as the first constructor argument.

`$care` is an array of event names you want to care about. This differs slightly between the *Counting* and *Timing* observers. For the *Counting* observer, any event can be counted independently. For the *Timing*observer, it uses the difference in time between `saving` and `saved` to submit the metric, so only the after-operation events can be observed: `created`, `saved`, `updated`, `deleted`, `restored`. This is also why custom observable events are not supported for the *Timing* observer (yet ... working on it, we're happy to take PRs).

Per NewRelic's "best practice" suggestions, all metric names are prefaced with 'Custom/'. The *Counting* observer also adds 'Counts/' to the name, while the *Timing* observer adds 'Timing/' to the name. Both observers append the event name to the end of the metric name. Take as an example, using the *Counting* observer on the `User` model monitoring the `created` event - the name would be: `Custom/Counts/App/User/created` (where `App/User` is the namespaced class name of the observed model with slashes reversed for NewRelic metric paths, or will be whatever you set in `$name`if supplied).

It is safe to run these observers in integration tests or interactive test environments as long as `newrelic.throw_if_not_installed` is set to `false`. Then if the NewRelic PHP Agent is not installed in that environment, the custom metrics will simply not be recorded. If the NewRelic PHP Agent is installed in that environment, the metrics will be recorded.

The default events both observers care about are: `created`, `saved`, `updated`, `deleted`, `restored`.

**NOTE:** To use the observers, the `Newrelic` Facade must be loaded in your application configuration, not just the Service Provider.

**NOTE:** NewRelic restricts the total number of custom metrics you can have to 2000, and recommends less than 1000.

#### Example Custom Metrics Dashboard

[](#example-custom-metrics-dashboard)

[![dashboard](dashboard.png)](dashboard.png)

Basic Use
---------

[](#basic-use)

This package includes a Facade to the [Intouch/Newrelic](http://github.com/In-Touch/newrelic) class.
Any of its methods may be accessed as any other Facade is accessed, for example:

```
App::after( function() {
    Newrelic::setAppName( 'MyApp' );
} );

```

... would set the NewRelic App Name to 'MyApp'

Laravel 4.x Support
-------------------

[](#laravel-4x-support)

Laravel VersionPackage TagSupported4.2.x[1.1.5](https://github.com/In-Touch/laravel-newrelic/tree/1.1.5)no4.1.x[1.1.5](https://github.com/In-Touch/laravel-newrelic/tree/1.1.5)no4.0.x[1.0.4](https://github.com/In-Touch/laravel-newrelic/tree/1.0.4)no\*we will review PRs for unsupported versions, but we don't use those versions in production ourselves so we aren'ttesting / working on that\*Issues
------

[](#issues)

Before opening an issues for data not reporting in the format you have configured, please check your NewRelic PHP Agent logs and please see: [https://discuss.newrelic.com/t/php-agent-4-19-0-disabled-3rd-party-service-provider-incorrectly/1666](https://discuss.newrelic.com/t/php-agent-4-19-0-disabled-3rd-party-service-provider-incorrectly/16667)

If that hasn't cleared things up, please open an issue here or send us a PR.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Recently: every ~202 days

Total

19

Last Release

2687d ago

Major Versions

1.1.5 → 2.0.02015-03-11

1.1.6 → 2.1.02016-05-05

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

2.0.0PHP &gt;=5.4.0

2.1.0PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/00eb5d1835592282f219210783b96f74a7072ade86fa2f0cbca5235ba7eeb924?d=identicon)[zfuming](/maintainers/zfuming)

---

Top Contributors

[![pleckey](https://avatars.githubusercontent.com/u/684580?v=4)](https://github.com/pleckey "pleckey (23 commits)")[![apancutt](https://avatars.githubusercontent.com/u/1040525?v=4)](https://github.com/apancutt "apancutt (4 commits)")[![emmanuelgautier](https://avatars.githubusercontent.com/u/2765366?v=4)](https://github.com/emmanuelgautier "emmanuelgautier (3 commits)")[![tomschlick](https://avatars.githubusercontent.com/u/70184?v=4)](https://github.com/tomschlick "tomschlick (3 commits)")[![daper](https://avatars.githubusercontent.com/u/5327718?v=4)](https://github.com/daper "daper (2 commits)")[![danwall](https://avatars.githubusercontent.com/u/827274?v=4)](https://github.com/danwall "danwall (2 commits)")[![bryceray1121](https://avatars.githubusercontent.com/u/985094?v=4)](https://github.com/bryceray1121 "bryceray1121 (2 commits)")[![altrim](https://avatars.githubusercontent.com/u/602300?v=4)](https://github.com/altrim "altrim (2 commits)")[![weotch](https://avatars.githubusercontent.com/u/77567?v=4)](https://github.com/weotch "weotch (1 commits)")[![wins1908](https://avatars.githubusercontent.com/u/8425263?v=4)](https://github.com/wins1908 "wins1908 (1 commits)")[![andrioli](https://avatars.githubusercontent.com/u/499182?v=4)](https://github.com/andrioli "andrioli (1 commits)")[![danhunsaker](https://avatars.githubusercontent.com/u/1534396?v=4)](https://github.com/danhunsaker "danhunsaker (1 commits)")[![hootlex](https://avatars.githubusercontent.com/u/6147968?v=4)](https://github.com/hootlex "hootlex (1 commits)")[![lukewaite](https://avatars.githubusercontent.com/u/618130?v=4)](https://github.com/lukewaite "lukewaite (1 commits)")[![mosanger](https://avatars.githubusercontent.com/u/281736?v=4)](https://github.com/mosanger "mosanger (1 commits)")[![paunin](https://avatars.githubusercontent.com/u/500074?v=4)](https://github.com/paunin "paunin (1 commits)")[![PhiloNL](https://avatars.githubusercontent.com/u/1133950?v=4)](https://github.com/PhiloNL "PhiloNL (1 commits)")

---

Tags

laravelnewrelicnew relic

### Embed Badge

![Health badge](/badges/zfuming-laravel-newrelic/health.svg)

```
[![Health](https://phpackages.com/badges/zfuming-laravel-newrelic/health.svg)](https://phpackages.com/packages/zfuming-laravel-newrelic)
```

###  Alternatives

[intouch/laravel-newrelic

Laravel 5 NewRelic Integration

1731.2M](/packages/intouch-laravel-newrelic)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[jackwh/laravel-new-relic

Monitor your Laravel application performance with New Relic

112827.2k](/packages/jackwh-laravel-new-relic)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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