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

ActiveLibrary

farayaz/laravel-spy
===================

A Laravel package to track outgoing HTTP requests.

v1.4.2(2mo ago)20810.4k↑40.9%12[1 PRs](https://github.com/farayaz/laravel-spy/pulls)MITPHPPHP ^8.1

Since May 6Pushed 2mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (6)Versions (20)Used By (0)

 [![Laravel Spy Logo](./laravel-spy.svg)](./laravel-spy.svg)

 [ ![Latest Version on Packagist](https://camo.githubusercontent.com/51eebeef67ff3289c28208561618c76ca69fa93ac2b741cbc1e021c4c9953fa9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6661726179617a2f6c61726176656c2d7370792e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/farayaz/laravel-spy) [ ![Total Downloads](https://camo.githubusercontent.com/e1eb369a6a5d592896a5369b9aeb13fe91d5c555ce71cc2c543cf2c75fbd5b94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6661726179617a2f6c61726176656c2d7370792e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/farayaz/laravel-spy) [ ![License](https://camo.githubusercontent.com/e5948552d7ae45c56368191b87c11466e02c205d1ccf80b6a91510d85b107a11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6661726179617a2f6c61726176656c2d7370792e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/farayaz/laravel-spy)

Laravel Spy
===========

[](#laravel-spy)

**Laravel Spy** is a lightweight Laravel package designed to track and log outgoing HTTP requests made by your Laravel application.

This package is useful for debugging, monitoring, and auditing external API calls or HTTP requests, providing developers with a zero config, simple way to inspect request details such as URLs, methods, headers, and responses.

Features
--------

[](#features)

- Tracks all outgoing HTTP requests made via Laravel's HTTP client.
- Logs request details, including URL, method, headers, payload, and response.
- Configurable logging options to customize and obfuscate sensitive data.

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

[](#requirements)

- **PHP**: ^8.1
- **Laravel**: ^10.0 | ^11.0 | ^12.0
- **Development Dependencies** (optional):
    - `laravel/pint`: ^1.0 (for code style linting)
    - `phpunit/phpunit`: ^9.0 (for running tests)

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

[](#installation)

You can install the package via Composer:

```
composer require farayaz/laravel-spy
```

The package uses Laravel's auto-discovery feature. After installation, the package is ready to use with its default configuration.

```
php artisan vendor:publish --provider="Farayaz\LaravelSpy\LaravelSpyServiceProvider"
```

```
php artisan migrate
```

Usage
-----

[](#usage)

Once installed and configured, Laravel Spy automatically tracks all outgoing HTTP requests made using Laravel's Http facade or HTTP client. The package logs the following details for each request:

- The full URL of the request
- The HTTP method (e.g., GET, POST, PUT)
- Request Headers
- Request Body
- Response Header
- Response Body
- Response HTTP Status code
- Request duration (milliseconds)

Example:
--------

[](#example)

After installing `laravel-spy` and publishing the configuration, any usage of Laravel's HTTP client (for example, in your controllers or jobs) will be automatically logged.

Laravel Spy will log the details of this outgoing request to the `http_logs` table in your database.

```
Http::get('https://github.com/farayaz/laravel-spy/');
```

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

[](#configuration)

To customize Laravel Spy, publish the config file and edit `config/spy.php`.

### Basic Configuration

[](#basic-configuration)

Configure these via environment variables:

```
SPY_ENABLED=true
```

### URL Exclusions

[](#url-exclusions)

Exclude specific URLs from being logged via environment variable:

```
SPY_EXCLUDE_URLS=api/health,ping,status
```

### Data Obfuscation

[](#data-obfuscation)

Laravel Spy can obfuscate sensitive data in your logs. By default, it obfuscates `password` and `token` fields, but you can customize this via environment variables:

```
SPY_OBFUSCATES=password,token,api_key,secret
SPY_OBFUSCATION_MASK=***HIDDEN***
```

### Excluding Content Types from Logging

[](#excluding-content-types-from-logging)

You can configure Laravel Spy to exclude specific content types from being logged for both request and response bodies. This is useful for binary data, images, videos, or other content you do not want included in logs.

```
SPY_REQUEST_BODY_EXCLUDE_CONTENT_TYPES=image/
SPY_RESPONSE_BODY_EXCLUDE_CONTENT_TYPES=video/,application/pdf
```

### Field Length and Row Limits

[](#field-length-and-row-limits)

Control field length and row limits:

```
SPY_FIELD_MAX_LENGTH=10000  # Maximum characters per field (default: 10000)
SPY_FIELD_MAX_ROWS=10000    # Maximum number of log entries to retain (default: 10000)
```

### Automatic Log Retention

[](#automatic-log-retention)

Configure how long logs should be retained before automatic cleanup via environment variable:

```
SPY_CLEAN_DAYS=7  # Keep logs for 7 days (default is 30)
```

Dashboard
---------

[](#dashboard)

Laravel Spy includes a simple built-in dashboard at `/spy` with:

```
SPY_DASHBOARD_ENABLED=true
SPY_DASHBOARD_MIDDLEWARE=web,auth
```

Cleaning up logs
----------------

[](#cleaning-up-logs)

Laravel Spy provides a `spy:clean` command to remove old HTTP logs:

```
# Clean logs based on your config
php artisan spy:clean

# Clean logs older than 30 days
php artisan spy:clean --days=30

# Clean logs matching URL pattern
php artisan spy:clean --days=1 --url=api/users
```

### Automated cleanup

[](#automated-cleanup)

You can schedule automatic cleanup in your Laravel scheduler:

```
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
  $schedule->command('spy:clean')->daily();
}
```

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

[](#contributing)

Contributions are welcome! To contribute to Laravel Spy:

- Fork the repository on GitHub.
- Clone your fork and create a new branch (git checkout -b feat-your-feature).
- Run code style checks with Laravel Pint (vendor/bin/pint).
- Commit your changes and push to your fork.
- Create a pull request with a clear description of your changes.

Issues
------

[](#issues)

If you encounter any issues or have feature requests, please open an issue on the GitHub repository. Provide as much detail as possible, including:

- Laravel version
- PHP version
- Package version
- Steps to reproduce
- Expected vs. actual behavior
- Any relevant error messages or logs

License
-------

[](#license)

Laravel Spy is open-sourced software licensed under the MIT License.

Contact
-------

[](#contact)

For questions or support, reach out via the GitHub repository or open an issue.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance83

Actively maintained with recent releases

Popularity44

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.9% 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 ~17 days

Recently: every ~43 days

Total

18

Last Release

86d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c16cac045960b0a19d89745d4abc9532c1da32c29bcfddfa4929658143b460fd?d=identicon)[mehrdadx10](/maintainers/mehrdadx10)

---

Top Contributors

[![mehrdadx10](https://avatars.githubusercontent.com/u/4258955?v=4)](https://github.com/mehrdadx10 "mehrdadx10 (39 commits)")[![rezakhademix](https://avatars.githubusercontent.com/u/70235203?v=4)](https://github.com/rezakhademix "rezakhademix (10 commits)")[![amirmms](https://avatars.githubusercontent.com/u/14109632?v=4)](https://github.com/amirmms "amirmms (9 commits)")[![murphatron](https://avatars.githubusercontent.com/u/30440375?v=4)](https://github.com/murphatron "murphatron (3 commits)")[![oveysrostami](https://avatars.githubusercontent.com/u/9713287?v=4)](https://github.com/oveysrostami "oveysrostami (1 commits)")

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11120.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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