PHPackages                             miquido/request-data-collector - 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. miquido/request-data-collector

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

miquido/request-data-collector
==============================

Library used to collect request data during its lifetime.

v2.4.0(5y ago)113.1k1Apache-2.0PHPPHP ^7.3|^8.0

Since Apr 1Pushed 4y ago2 watchersCompare

[ Source](https://github.com/miquido/request-data-collector)[ Packagist](https://packagist.org/packages/miquido/request-data-collector)[ Docs](https://github.com/miquido/request-data-collector)[ RSS](/packages/miquido-request-data-collector/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (12)Versions (13)Used By (1)

Requests Data Collector
=======================

[](#requests-data-collector)

With this package one can easily start collecting various data that comes through Laravel. It is possible to gain control over excessive database queries and more by analyzing logs.

This package aims to work as a zero-configuration. Although there are default configurations for existing data collectors, take your time to adjust them to own needs. Also, feel free to add own data collectors.

When using this package, every handled request (i.e. not excluded according to `exclusions` rules) will contain `X-Request-Id` header in the response. You can use this ID to correlate various collectors' data.

[![GitHub license](https://camo.githubusercontent.com/4279c32da8d46c99eab26468d60706d159657a8c31c0ed99e20e9f3ad97b5bdd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865322e302d627269676874677265656e2e737667)](https://github.com/miquido/request-data-collector/blob/master/LICENSE)[![Build](https://github.com/miquido/request-data-collector/workflows/PHP/badge.svg?branch=master)](https://github.com/miquido/request-data-collector/actions?query=branch%3Amaster)

Set up
------

[](#set-up)

### Laravel 5.6+

[](#laravel-56)

If You are not using auto-discovery feature, register package's service provider in `config/app.php` file:

```
	'providers' => [
		// ...
		\Miquido\RequestDataCollector\Providers\LaravelServiceProvider::class,
	],
```

### Lumen

[](#lumen)

Register package's service provider in `bootstrap/app.php` file:

```
$app->register(\Miquido\RequestDataCollector\Providers\LumenServiceProvider::class);
```

If You want to override default configuration, don't forget to copy the default one to `/config/request-data-collector.php` file and load it in `bootstrap/app.php` file:

```
$app->configure('request-data-collector');
```

### Further configuration

[](#further-configuration)

Add new environment variable (e.g. to `.env` file):

```
REQUESTS_DATA_COLLECTOR_ENABLED=true
```

That's it! By default, only basic information about requests are collected and pushed to logs (according to `LOG_CHANNEL` channel).

### Publishing default configuration

[](#publishing-default-configuration)

```
php artisan vendor:publish --provider="Miquido\RequestDataCollector\Providers\LaravelServiceProvider"
```

Available Data Collectors
-------------------------

[](#available-data-collectors)

There are some predefined Data Collectors that might be used.

### RequestResponseCollector

[](#requestresponsecollector)

This collector is used to collect data about the incoming request and ongoing response.

```
'request' => [
	'driver' => \Miquido\RequestDataCollector\Collectors\RequestResponseCollector::class,

	'request_info' => [
		// ...
	],

	'response_info' => [
		// ...
	],

	'variables' => [
		// ...
	],

	'raw' => boolean,
],
```

#### request\_info

[](#request_info)

Defines a list of request parameters that should be collected. For list of available options, see `\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::REQUEST_INFO_*` constants.

Example:

```
'request_info' => [
	\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::REQUEST_INFO_REAL_METHOD,
	\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::REQUEST_INFO_PATH_INFO,
],
```

#### response\_info

[](#response_info)

Defines a list of response parameters that should be collected. For list of available options, see `\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::RESPONSE_INFO_*` constants.

Example:

```
'response_info' => [
	\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::RESPONSE_INFO_HTTP_STATUS_CODE,
],
```

#### variables

[](#variables)

Defines a list of variables associated with request that should be collected. For list of available options, see `\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::VARIABLE_*` constants.

It is possible to collect all information about variable:

```
'variables' => [
	\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::VARIABLE_GET,
],
```

Or include/exclude some of them (which is especially useful when dealing with sensitive data):

```
// Incoming request: /some/page?email=...&password=...

'variables' => [
	\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::VARIABLE_GET => [
		'excludes' => [
			'password',
		],

		'includes' => [
			'email',
		],
	],
],
```

It is worth mentioning, that **inclusions have priority over exclusions**. This means if inclusions are used, exclusions are not applied at all.

#### raw

[](#raw)

When set to `true`, request will be remembered as soon as reaches application (allows to have unmodified request). When set to `false`, data collection will use request at the end of application lifetime (allows to include request modifications).

Please note that raw request does not have routing information, so `\Miquido\RequestDataCollector\Collectors\RequestResponseCollector::REQUEST_INFO_ROUTE` option will not have effect.

### DatabaseQueriesCollector

[](#databasequeriescollector)

This collector is used to collect data about performed database queries.

Please note, that it uses Laravel's built-in `\DB::enable/disable/flushQueryLog()` methods, so if it is also used somewhere else in the code, it might have impact on the final result.

```
'database' => [
	'driver' => \Miquido\RequestDataCollector\Collectors\DatabaseQueriesCollector::class,

	'connections' => [
		// ...
	],
],
```

#### connections

[](#connections)

Defines a list of connections to databases from which queries should be collected. Use names defined in `config/database.php` file. It is also possible to provide `null` value as a name to collect queries from default connection.

Enabling or disabling Data Collectors
-------------------------------------

[](#enabling-or-disabling-data-collectors)

Each collector's configuration consists of two parts: entry in `collectors` array and entry in `options` array.

The `collectors` array contains key-value entries, where key is collector name and value is either `true` or `false`, depending on if it should be enabled or disabled. Suggestion: if it is required to dynamically enable/disable specified collectors, one might want to define different environmental variables for each collector itself (e.g. `DATABASE_COLLECTOR_ENABLED` etc.).

The `options` array contains key-value entries, where key is collector name and value is an array with its configuration. It is required for it to have at least `driver` setting. Every other settings are collector dependent.

The `key` with collector name will be used for logging purposes. Every log entry contains information about request ID and given collector name to easier find/filter it.

Excluding requests from collecting
----------------------------------

[](#excluding-requests-from-collecting)

It is possible to exclude some requests that should not be collected at all.

```
'exclude' => [
	[
		'filter' => class reference,
		'with'   => [
			// ...
		],
	],

	// ...
],
```

Each entry consists of:

**filter** containing filter class reference (e.g. `\Miquido\RequestDataCollector\Filters\UserAgentFilter::class`).

**with** containing data provided for filter class constructor (e.g. `'userAgents' => ['Docker HEALTHCHECK'], ...`). Note: Laravel's container is used here so it is possible to make use of Dependency Injection.

Feel fre to use one of available filters (see `src/Filters` directory) or write your own.

Tracking the request through many services
------------------------------------------

[](#tracking-the-request-through-many-services)

You can track request through many services. When `Request ID` is being generated, it is firstly checked if there is `X-REQUEST-ID` header present in the request, and its value is being used instead. This way You can see same `Request ID` in logs.

When there is no `X-REQUEST-ID` header available, You can still set Your custom `Request ID` via `\Miquido\RequestDataCollector\RequestDataCollector::setRequestId()` method.

In both cases `Request ID` has to be in following format:

`X[0-9a-fA-F]{32}`

If `X-REQUEST-ID` has invalid format it will be silently skipped and new ID will be generated.

By default, tracking is enabled. However, it can be disabled:

```
REQUESTS_DATA_COLLECTOR_ALLOW_TRACKING=false
```

About
-----

[](#about)

The project was made by Miquido:

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~67 days

Recently: every ~139 days

Total

12

Last Release

1902d ago

Major Versions

v1.2.1 → v2.0.02019-06-25

PHP version history (3 changes)v1.0.0PHP &gt;=7.2

v2.3.0PHP &gt;=7.3

v2.4.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d2443c24cf5869099ca69ba917cca98e9c0884a8d5bc29d65fe872a9f54665a?d=identicon)[donatorsky](/maintainers/donatorsky)

---

Top Contributors

[![donatorsky](https://avatars.githubusercontent.com/u/5360041?v=4)](https://github.com/donatorsky "donatorsky (24 commits)")[![ljazgar](https://avatars.githubusercontent.com/u/2005098?v=4)](https://github.com/ljazgar "ljazgar (1 commits)")

---

Tags

laravelmonitoringphprequestcollectordata collectorrequest-data-collector

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/miquido-request-data-collector/health.svg)

```
[![Health](https://phpackages.com/badges/miquido-request-data-collector/health.svg)](https://phpackages.com/packages/miquido-request-data-collector)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k28.4M137](/packages/laravel-cashier)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M154](/packages/spatie-laravel-health)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9772.3M122](/packages/roots-acorn)[laravel/ai

The official AI SDK for Laravel.

1.0k2.1M163](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

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