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

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

atatus/laravel-atatus
=====================

Atatus PHP Middleware for Laravel

1.0.2(2y ago)110.4k↑75%Apache-2.0PHPPHP &gt;=5.4.0

Since Jun 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/atatus/laravel-atatus)[ Packagist](https://packagist.org/packages/atatus/laravel-atatus)[ Docs](https://www.atatus.com)[ RSS](/packages/atatus-laravel-atatus/feed)WikiDiscussions master Synced 1mo ago

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

Atatus Laravel Middleware
=========================

[](#atatus-laravel-middleware)

Atatus Laravel Middleware allows for the automatic capture of API calls and sends them to [Atatus API analytics](https://www.atatus.com).

How to install
--------------

[](#how-to-install)

Via Composer

```
$ composer require atatus/laravel-atatus
```

or add 'atatus/laravel-atatus' to your composer.json file accordingly.

How to use
----------

[](#how-to-use)

### Add Service Provider

[](#add-service-provider)

```
// In config/app.php

'providers' => [
  /*
   * Application Service Providers...
   */
    Atatus\Middleware\AtatusLaravelServiceProvider::class,
];
```

### Add to Middleware

[](#add-to-middleware)

If website root is your API, add to the root level:

```
// In App/Http/Kernel.php

protected $middleware = [
  /*
   * The application's global HTTP middleware stack.
   *
   * These middleware are run during every request to your application.
   */
   \Atatus\Middleware\AtatusLaravel::class,
];
```

If you only want to add tracking for APIs under specific route group, add to your route group, but be sure to remove from the global middleware stack from above global list.

```
// In App/Http/Kernel.php

protected $middlewareGroups = [
  /**
   * The application's API route middleware group.
   */
   'api' => [
        //
        \Atatus\Middleware\AtatusLaravel::class,
    ],
];
```

To track only certain routes, use route specific middleware setup.

### Publish the package config file

[](#publish-the-package-config-file)

```
$ php artisan vendor:publish --provider="Atatus\Middleware\AtatusLaravelServiceProvider"
```

### Setup config

[](#setup-config)

Edit `config/atatus.php` file.

```
// In config/atatus.php

return [
    'logBody' => true,
    // 'debug' => false,
    // 'configClass' => 'MyApp\\MyConfigs\\CustomAtatusConfig'
];
```

For other configuration options, see below.

Configuration options
---------------------

[](#configuration-options)

You can define Atatus configuration options in the `config/atatus.php` file.

#### **`logBody`**

[](#logbody)

Type: `Boolean`Optional, Default true, Set to false to remove logging request and response body to Atatus.

#### **`debug`**

[](#debug)

Type: `Boolean`Optional, Default false, Set to true to print debug messages using Illuminate\\Support\\Facades\\Log

#### **`configClass`**

[](#configclass)

Type: `String`Optional, a string for the full path (including namespaces) to a class containing additional functions. The class can reside in any namespace, as long as the full namespace is provided.

example:

```
return [
    'logBody' => true,
    'debug' => false,
    'configClass' => 'MyApp\\MyConfigs\\CustomAtatusConfig'
];
```

Configuration class **(Optional)**
----------------------------------

[](#configuration-class-optional)

Because configuration hooks and functions cannot be placed in the `config/atatus.php` file, these reside in a PHP class that you create. Set the path to this class using the `configClass` option. You can define any of the following hooks:

#### **`identifyUserId`**

[](#identifyuserid)

Type: `($request, $response) => String`Optional, a function that takes a $request and $response and return a string for userId. Atatus automatically obtains end userId via $request-&gt;user()\['id'\], In case you use a non standard way of injecting user into $request or want to override userId, you can do so with identifyUserId.

#### **`identifyCompanyId`**

[](#identifycompanyid)

Type: `($request, $response) => String`Optional, a function that takes a $request and $response and return a string for companyId.

#### **`maskRequestBody`**

[](#maskrequestbody)

Type: `$body => $body`Optional, a function that takes a $body, which is an associative array representation of JSON, and returns an associative array with any information removed.

#### **`maskResponseBody`**

[](#maskresponsebody)

Type: `$body => $body`Optional, same as above, but for Responses.

Example config class

```
namespace MyApp\MyConfigs;

class CustomAtatusConfig
{

    public function maskRequestBody($body) {
      return $body;
    }

    public function maskResponseBody($body) {
      return $body;
    }

    public function identifyUserId($request, $response) {
      if (is_null($request->user())) {
        return null;
      } else {
        $user = $request->user();
        return $user['id'];
      }
    }

    public function identifyCompanyId($request, $response) {
      return "comp_acme_corporation";
    }

}
```

- In your `config/atatus.php` file:

```
return [
    'logBody' => true,
    'debug' => false,
    'configClass' => 'MyApp\\MyConfigs\\CustomAtatusConfig'
]
```

Be sure to update cache after changing config:
----------------------------------------------

[](#be-sure-to-update-cache-after-changing-config)

If you enabled config cache, after you update the configuration, please be sure to run `php artisan config:cache` again to ensure configuration is updated.

Credits
-------

[](#credits)

- Mixpanel's PHP client
- Moesif Laravel Middlware
- Jonny Pickett

### The PHP JSON extension is required.

[](#the-php-json-extension-is-required)

Make sure you install PHP with the JSON Extension enabled [More Info](https://stackoverflow.com/questions/7318191/enable-json-encode-in-php).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~5 days

Total

3

Last Release

1060d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82a726c025bc988a34b50ee085cff12504f237b6faab160bdb7df1b248836a7d?d=identicon)[atatus](/maintainers/atatus)

---

Top Contributors

[![fizerkhan](https://avatars.githubusercontent.com/u/1433380?v=4)](https://github.com/fizerkhan "fizerkhan (2 commits)")[![saranRe](https://avatars.githubusercontent.com/u/111440681?v=4)](https://github.com/saranRe "saranRe (2 commits)")

---

Tags

middlewareapilaraveldebuggingapmanalyticsatatus

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[moesif/moesif-laravel

Moesif Collection/Data Ingestion Middleware for Laravel

1065.8k](/packages/moesif-moesif-laravel)

PHPackages © 2026

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