PHPackages                             inspector-apm/inspector-slim - 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. inspector-apm/inspector-slim

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

inspector-apm/inspector-slim
============================

Simple Code Execution Monitoring for Slim applications.

0.1.2(3y ago)01.8kMITPHPPHP &gt;=7.2

Since Jan 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/inspector-apm/inspector-slim)[ Packagist](https://packagist.org/packages/inspector-apm/inspector-slim)[ RSS](/packages/inspector-apm-inspector-slim/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (7)Used By (0)

Inspector | Code Execution Monitoring Tool
==========================================

[](#inspector--code-execution-monitoring-tool)

[![Total Downloads](https://camo.githubusercontent.com/da0a08492130e33a1029086325f42bcb0ac055720cd234e4a40733054c9bd0f2/68747470733a2f2f706f7365722e707567782e6f72672f696e73706563746f722d61706d2f696e73706563746f722d736c696d2f646f776e6c6f616473)](//packagist.org/packages/inspector-apm/inspector-slim)[![Latest Stable Version](https://camo.githubusercontent.com/80d41d99e4a621983c7313bd80b93e08fb19a58f48b8049f2b41b8c4d8d4a456/68747470733a2f2f706f7365722e707567782e6f72672f696e73706563746f722d61706d2f696e73706563746f722d736c696d2f762f737461626c65)](https://packagist.org/packages/inspector-apm/inspector-slim)[![License](https://camo.githubusercontent.com/bb1994a82e0eb3ce1c34fc6f618c6caab57af4829de2bb05f40b273a186694e4/68747470733a2f2f706f7365722e707567782e6f72672f696e73706563746f722d61706d2f696e73706563746f722d736c696d2f6c6963656e7365)](//packagist.org/packages/inspector-apm/inspector-slim)[![Contributor Covenant](https://camo.githubusercontent.com/4ae39ae593b602cf0ae07972b61c73728b77ec8e2cf40f579a2441948208036b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f6e7472696275746f72253230436f76656e616e742d322e312d3462616161612e737667)](code_of_conduct.md)

Simple code execution monitoring for Slim framework based applications.

- [Requirements](#requirements)
- [Install](#install)
- [Middleware](#middleware)
- [Test](#test)
- [Add Segment](#segment)
- [Official Documentation](https://docs.inspector.dev/guides/slim)
- [Contribution Guidelines](#contribution)

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

[](#requirements)

- PHP &gt;= 7.2.0
- Slim &gt;= 4.x

Install
-------

[](#install)

Install the latest version by:

```
composer require inspector-apm/inspector-slim

```

### Register On Container

[](#register-on-container)

First you have to register the Inspector instance inside the application container in order to make the monitoring agent available within the application.

```
$container->set('inspector', function () {
    $configuration = new \Inspector\Slim\Configuration('INSPECTOR_INGESTION_KEY');

    return new Inspector($configuration);
});
```

Consider to use [environment variables](https://github.com/vlucas/phpdotenv) to store your project's INGESTION KEY.

If you are using a Slim 4 skeleton you can add a new container definition in `app/dependencies.php` file:

```
use DI\ContainerBuilder;
use Psr\Container\ContainerInterface;

return function (ContainerBuilder $containerBuilder) {
    $containerBuilder->addDefinitions([
        // Other services definitions...

        'inspector' => function (ContainerInterface $container) {
            $configuration = new \Inspector\Slim\Configuration('INSPECTOR_INGESTION_KEY');
            return new Inspector\Inspector($configuration);
        }

    ]);
}
```

You can get an `INSPECTOR_INGESTION_KEY` creating a new project in your [Inspector](https://www.inspector.dev) account.

Attach the Middleware
---------------------

[](#attach-the-middleware)

You can attach the middleware globally:

```
$app->add(\Inspector\Slim\WebRequestMonitoring::class);
```

Or in specific routes:

```
$app->get('/', function () {

    // your code here...

})->add(\Inspector\Slim\WebRequestMonitoring::class);
```

Test that everything works
--------------------------

[](#test-that-everything-works)

Create a test route and open it in the browser :

```
$app->get('/test', function () {

    throw new \Exception('My First Exception.');

})->add(\Inspector\Slim\WebRequestMonitoring::class);
```

Add Segment
-----------

[](#add-segment)

You can add segments to the transaction's timeline from route functions:

```
$app->get('/', function (Request $request, Response $response) {
    /*
     * Retrieve the inspector instance from the container.
     */
    $this->get('inspector')->addSegment(function () {

        // Your code here...
        sleep(1);

    }, 'sleep');

    return $response;
});
```

If your routes are organized using controllers you need to inject the container in the controller constructor:

```
namespace App\Controllers;

use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class TestController
{
    protected $container;

    /**
     * Inject the container to retrieve the inspector instance later.
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function __invoke(Request $request, Response $response)
    {
        // Retrieve the inspector instance from the container.
        $this->container->get('inspector')->addSegment(function () {

            // Your code here...
            sleep(1);

        }, 'sleep');

        $response->getBody()->write('Test route.');

        return $response;
    }
}
```

Official documentation
----------------------

[](#official-documentation)

**[Check out the official documentation](https://docs.inspector.dev/guides/slim)**

Contributing
------------

[](#contributing)

We encourage you to contribute to Inspector! Please check out the [Contribution Guidelines](CONTRIBUTING.md) about how to proceed. Join us!

LICENSE
-------

[](#license)

This package is licensed under the [MIT](LICENSE) license.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

1208d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/320345fbe48c7cff2b3a25992c8207e959ae7817fb2fb97bb176dc6e559aacf5?d=identicon)[valerione](/maintainers/valerione)

---

Top Contributors

[![ilvalerione](https://avatars.githubusercontent.com/u/13559278?v=4)](https://github.com/ilvalerione "ilvalerione (13 commits)")

---

Tags

error-handlingerror-monitoringerror-reportinginspectormonitoringmonitoring-toolphpmonitoringsliminspector

### Embed Badge

![Health badge](/badges/inspector-apm-inspector-slim/health.svg)

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

###  Alternatives

[inspector-apm/inspector-laravel

Code Execution Monitoring, built for developers.

2332.0M2](/packages/inspector-apm-inspector-laravel)[ptrofimov/beanstalk_console

Admin console for Beanstalk queue server

1.3k124.7k](/packages/ptrofimov-beanstalk-console)[inspector-apm/inspector-php

Inspector monitoring for PHP applications.

342.4M15](/packages/inspector-apm-inspector-php)[inspector-apm/inspector-symfony

Code Execution Monitoring for Symfony applications.

2830.1k2](/packages/inspector-apm-inspector-symfony)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)

PHPackages © 2026

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