PHPackages                             always-open/laravel-request-logger - 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. always-open/laravel-request-logger

ActiveLibrary

always-open/laravel-request-logger
==================================

Micro-package to ease the effort to log HTTP requests made from your application

v3.0.0(8mo ago)032.4k↓31.1%25MITPHPPHP ^8.2.0|^8.3.0|^8.4.0CI passing

Since Apr 21Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/always-open/laravel-request-logger)[ Packagist](https://packagist.org/packages/always-open/laravel-request-logger)[ Docs](https://github.com/always-open/laravel-request-logger)[ RSS](/packages/always-open-laravel-request-logger/feed)WikiDiscussions 3.x Synced 1mo ago

READMEChangelog (9)Dependencies (11)Versions (15)Used By (5)

Laravel Request Logger
======================

[](#laravel-request-logger)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8ea42685688add341b992905acf74af0b28663b86487d8e85c8e0c95ce562b0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c776179732d6f70656e2f6c61726176656c2d726571756573742d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/always-open/laravel-request-logger)[![Build Status](https://camo.githubusercontent.com/7c794f79c0464463e0a17f1393230fa4626b7d9c3effe1a350ed91332278e8eb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f616c776179732d6f70656e2f6c61726176656c2d726571756573742d6c6f676765722f72756e2d74657374732f6d61696e)](https://github.com/always-open/laravel-request-logger/actions?query=workflow%3Arun-tests)[![GitHub Workflow Status (branch)](https://camo.githubusercontent.com/18e8253a00cd417a65b519c54c891263112e45521b1c6f3f782b0bc8601a28f6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f616c776179732d6f70656e2f6c61726176656c2d726571756573742d6c6f676765722f5048505374616e2f6d61696e3f6c6162656c3d5048505374616e)](https://github.com/always-open/laravel-request-logger/actions?query=workflow%3APHPStan)[![Packagist Downloads](https://camo.githubusercontent.com/c6e2d2aacf3794ee8d44cda2a9d0dbe391d3205190511d309fc9576e1daf4731/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c776179732d6f70656e2f6c61726176656c2d726571756573742d6c6f67676572)](https://packagist.org/packages/always-open/laravel-request-logger)

[![Maintainability](https://camo.githubusercontent.com/64aa1076ae5690da6746d47fe95abb412f994a91e9dd56c11b09a9f8fe871388/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35303532333835396561643262616635643661662f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/always-open/laravel-request-logger/maintainability)

When making HTTP requests to external APIs it is valuable to track each request and its response. This insight can help you find issues, track usage, and reuse responses for testing/development.

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

[](#installation)

You can install the package via composer:

```
composer require always-open/laravel-request-logger
```

### Breaking change

[](#breaking-change)

If you are upgrading to 3.x or newer, the following steps must be taken as new fields have been added to the logging tables.

- Create a migration for each logging tables with the following

```
// The headers that were part of the request
$table->json('request_headers')
    ->nullable();
// The headers that were part of the response
$table->json('response_headers')
    ->nullable();
```

Run this migration prior to upgrading the package.

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

[](#configuration)

```
php artisan vendor:publish --provider="\AlwaysOpen\RequestLogger\RequestLoggerServiceProvider"
```

Running the above command will publish the config file.

Usage
-----

[](#usage)

### Creation

[](#creation)

To add logs to your system you must first create the migration and model for the appropriate log. This is done by using the packages `request-logger:make-table` command.

The command needs the name of the item to be tracked and it will be used for naming the model and table.

#### Example

[](#example)

```
php artisan request-logger:make-table facebook
```

This will create a model `\App\Models\FacebookRequestLog` and a migration to create the table `facebook_request_logs`

### Implementation

[](#implementation)

Then you can use that model to create logs of your requests where you can make the API calls.

#### Example

[](#example-1)

##### Guzzle

[](#guzzle)

```
function makeFacebookApiCall(array $body, Client $facebook_client)
{
    $request_headers = [
        'api-key' => $config->apiKey,
        'Content-Type' => 'application/json',
    ];

    $versioned_path = self::buildVersionedUrlPath($path);

    $encoded_body = json_encode($body, JSON_UNESCAPED_SLASHES);

    $request = new Request(
        'GET',
        '/v1/users',
        $request_headers,
        $encoded_body,
    );

    $request_log = FacebookRequestLog::makeFromGuzzle($request);

    $response = $client->send($request);

    $request_log->response_code = $response->getStatusCode();
    $request_log->response = json_decode((string)$response->getBody(), true);
    $request_log->save();
}
```

Instead of manually setting the response data you can instead leverage the `updateFromResponse` method:

```
function makeFacebookApiCall(array $body, Client $facebook_client)
{
    $request_headers = [
        'api-key' => $config->apiKey,
        'Content-Type' => 'application/json',
    ];

    $versioned_path = self::buildVersionedUrlPath($path);

    $encoded_body = json_encode($body, JSON_UNESCAPED_SLASHES);

    $request = new Request(
        'GET',
        '/v1/users',
        $request_headers,
        $encoded_body,
    );

    $request_log = FacebookRequestLog::makeFromGuzzle($request);

    $response = $client->send($request);
    $request_log->updateFromResponse($response);
}
```

You can also manually set each property and then save the log instance.

### Testing

[](#testing)

```
composer test
```

### Using Docker

[](#using-docker)

All assets are set up under the docker-compose.yml file. The first time you run the docker image you must build it with the following command:

```
./docker.sh -b -s
```

Then you can bring it up in the background using:

```
./docker.sh -d
```

From there you can run the tests within an isolated environment

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email @qschmick instead of using the issue tracker.

Credits
-------

[](#credits)

- [Quentin Schmick](https://github.com/qschmick)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance59

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity73

Established project with proven stability

 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 ~102 days

Recently: every ~282 days

Total

13

Last Release

257d ago

Major Versions

v0.1.3 → 1.x-dev2022-04-22

1.x-dev → v2.0.02022-04-22

v2.2.1 → 3.x-dev2025-09-03

PHP version history (3 changes)v0.1.0PHP ^8.0|^8.1

v2.0.1PHP ^8.0.0|^8.1.0

3.x-devPHP ^8.2.0|^8.3.0|^8.4.0

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

hacktoberfestlaravelloggerlaravelhttp requestalways-openrequest logger

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/always-open-laravel-request-logger/health.svg)

```
[![Health](https://phpackages.com/badges/always-open-laravel-request-logger/health.svg)](https://phpackages.com/packages/always-open-laravel-request-logger)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)[vemcogroup/laravel-sparkpost-driver

SparkPost driver to use with Laravel 6.x|7.x|8.x|9.x|10.x

421.7M1](/packages/vemcogroup-laravel-sparkpost-driver)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

97139.6k2](/packages/nickurt-laravel-akismet)

PHPackages © 2026

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