PHPackages                             herloct/slim-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. [Framework](/categories/framework)
4. /
5. herloct/slim-newrelic

ActiveLibrary[Framework](/categories/framework)

herloct/slim-newrelic
=====================

New Relic instrumentation for the Slim framework

211.2kPHP

Since Mar 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/herloct/slim-newrelic)[ Packagist](https://packagist.org/packages/herloct/slim-newrelic)[ RSS](/packages/herloct-slim-newrelic/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

slim-newrelic
=============

[](#slim-newrelic)

[![Build Status](https://camo.githubusercontent.com/770cca9ba245c00b071668132534dde2e0783f32f10c52fcd3e14b6631aee2fc/68747470733a2f2f7472617669732d63692e6f72672f6865726c6f63742f736c696d2d6e657772656c69632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/herloct/slim-newrelic)[![Test Coverage](https://camo.githubusercontent.com/de1d34de5837a84d09ba3ac3d27cdbbeb2932f96a36ea15f9cf34e6f5bb3bdab/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6865726c6f63742f736c696d2d6e657772656c69632f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/herloct/slim-newrelic/coverage)[![Code Climate](https://camo.githubusercontent.com/727ffcbff3b982793eaa4d17f0db9c6d8986e61f85ede569a1a2b7a190d4c50e/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6865726c6f63742f736c696d2d6e657772656c69632f6261646765732f6770612e737667)](https://codeclimate.com/github/herloct/slim-newrelic)[![license](https://camo.githubusercontent.com/25fbe8c3132e5a24ec94a3252782ff5d735241295d8821029b2367f791581c48/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6865726c6f63742f736c696d2d6e657772656c69632e737667)](herloct/slim-newrelic)

This library provides New Relic instrumentation for the Slim framework. When installed this library will ensure that your transactions are properly named and that your exceptions are properly logged in New Relic.

Using @nordsoftware's [nordsoftware/lumen-newrelic](https://github.com/nordsoftware/lumen-newrelic) as reference.

License
-------

[](#license)

See [LICENSE](LICENSE)

Requirements
------------

[](#requirements)

- PHP 5.6 or newer
- [Composer](http://getcomposer.org)
- [Slim](https://www.slimframework.com/) 3.7 or newer

Usage
-----

[](#usage)

### Installation

[](#installation)

Run the following command to install the package through Composer:

```
composer require herloct/slim-newrelic
```

### Bootstrapping

[](#bootstrapping)

Example `index.php`.

```
$config = [
    'settings' => [
        'displayErrorDetails' => true,

        // These two are needed so new relic agent could work
        'addContentLengthHeader' => false,
        'determineRouteBeforeAppMiddleware' => true
    ],

    'errorHandler' => function ($c) {
        $agent = $c->get(\SobanVuex\NewRelic\Agent::class);
        $errorHandler = new \Slim\Handlers\Error($c->get('settings')['displayErrorDetails']);

        return new \Herloct\Slim\Handlers\NewRelicError($agent, $errorHandler);
    },

    \SobanVuex\NewRelic\Agent::class => function ($c) {
        $agent = new \SobanVuex\NewRelic\Agent(
            'Your Application Name',
            'YOUR_NEW_RELIC_LICENSE_KEY'
        );

        return $agent;
    },

    \Herloct\Slim\NewRelicTransactionMiddleware::class => function ($c) {
        $agent = $c->get(\SobanVuex\NewRelic\Agent::class);

        return new \Herloct\Slim\NewRelicTransactionMiddleware($agent);
    }
];

$app = new \Slim\App($config);
$app->add(\Herloct\Slim\NewRelicTransactionMiddleware::class);

$app->get('/hello/{name}', function ($request, $response, $args) {
    return $response->write("Hello " . $args['name']);
})->setName('say_hello');

$app->run();
```

Customizing transaction names
-----------------------------

[](#customizing-transaction-names)

By default the transaction name will use the route's name. If that fails, it will use the route's pattern.

If this doesn't meet your requirements, extend the `Herloct\Slim\NewRelicTransactionMiddleware` class and override the `getTransactionName()` method, then register that middleware class instead.

Running tests
-------------

[](#running-tests)

Clone the project and install its dependencies by running:

```
composer install
```

Run the following command to run the test suite:

```
vendor/bin/phpunit
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1674009?v=4)[Herloct](/maintainers/herloct)[@herloct](https://github.com/herloct)

---

Top Contributors

[![herloct](https://avatars.githubusercontent.com/u/1674009?v=4)](https://github.com/herloct "herloct (21 commits)")

---

Tags

newrelicphpslim-framework

### Embed Badge

![Health badge](/badges/herloct-slim-newrelic/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M844](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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