PHPackages                             moktech/mocklogger-sdk - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. moktech/mocklogger-sdk

ActiveLibrary[HTTP &amp; Networking](/categories/http)

moktech/mocklogger-sdk
======================

Mocklogger SDK is a Laravel package designed to facilitate effortless integration with the Mocklogger logging tool for developers.

1.0.92(2y ago)21371MITPHPPHP ^7.3|^8.0

Since Jan 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Muchwat/mocklogger-sdk)[ Packagist](https://packagist.org/packages/moktech/mocklogger-sdk)[ Docs](https://github.com/Muchwat/mocklogger-sdk)[ RSS](/packages/moktech-mocklogger-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

MockLogger SDK Documentation
----------------------------

[](#mocklogger-sdk-documentation)

MockLogger SDK offers functionality for logging request and response data of a Laravel application. This SDK provides methods to capture and log data pertaining to incoming HTTP requests and their associated responses.

With the MockLogger SDK, you can easily capture and log data from HTTP requests and responses, helping you monitor and analyze your application's interactions with external services and users actions.

### Installation

[](#installation)

To get started with the MockLogger SDK, follow these installation steps:

#### Install the SDK:

[](#install-the-sdk)

Install the MockLogger SDK using Composer:

```
composer require moktech/mocklogger-sdk
```

#### Publish Configuration:

[](#publish-configuration)

Publish the MockLogger SDK configuration file using Artisan:

```
php artisan vendor:publish --tag=mocklogger-config
```

#### Register Service Provider:

[](#register-service-provider)

Open the `config/app.php` file and add the service provider to the providers array:

```
'providers' => [
    // ...
    Moktech\MockLoggerSDK\MockloggerServiceProvider::class,
],
```

#### Set Environment Variables:

[](#set-environment-variables)

Set the following environment variables in your application's `.env`. You can obtain these values from your Mocklogger application:

```
MOCKLOGGER_HOST_URL=http://localhost:8000
MOCKLOGGER_APP_ID="My Application"
MOCKLOGGER_APP_KEY=c3ce75317d9c876d209a9f439b345345
MOCKLOGGER_APP_API_TOKEN=EomxCzUG0HFukdRWgKL26ThXuRstFTW
```

### Usage

[](#usage)

Once you have installed the MockLogger SDK and configured your environment, you can now use it to log request and response data. Here are two ways to use the SDK:

#### Method 1: Using sendLog

[](#method-1-using-sendlog)

Use this in your Terminable Middleware (Sunctum protected URL).

```
use Moktech\MockLoggerSDK\MockLogger;

class TerminableMiddleware
{
    protected $logger;

    public function __construct(MockLogger $logger)
    {
        $this->logger = $logger;
    }

    public function handle(Request $request, Closure $next): Response
    {
        return $next($request);
    }

    public function terminate(Request $request, Response $response)
    {
        try {
            $this->logger->sendLog($request, $response);
        } catch (\Throwable $th) {
            Log::info($th->getMessage());
        }
    }
}
```

#### Method 2: Using sendData

[](#method-2-using-senddata)

You can also manually assemble the request and response data and use the sendData method to log it.

```
use Moktech\MockLoggerSDK\MockLogger;

$data = [
    "request" => [
        'user' => [
            'name' => 'Kevin Muchwat',
            'email' => 'kevinmuchwat@gmail.com',
        ],
        'ip_address' => $request->ip(),
        'full_url' => $request->fullUrl(),
        'route_name' => $request->route()->getName(),
        'method' => $request->method(),
        'payload' => $request->all(),
        'agent' => $request->userAgent(),
    ],
    "response" => [
        'status_code' => $response->getStatusCode(),
        'content' => $response->getContent(),
        'format' => $response->headers->get('content-type'),
        'location' => $response->headers->get('location'),
    ],
];

$logger = new MockLogger();
$logger->sendData($data);
```

#### Server Health Monitoring

[](#server-health-monitoring)

MockLogger SDK empowers you to maintain optimal server performance by allowing you to set usage limits on CPU, memory, and hard disk space. If any of these limits are exceeded, the SDK automatically sends a detailed log to administrator's email configured in `config/mocklogger.php`.

```
return [
    ...
    // Configure server health monitor.
    'monitor' => [
        // Specify the web server service running, e.g., 'nginx' or 'apache2'.
        'server_service' => 'nginx',

        // Set email configuarations, default is 4 emails per 30mins interval.
        'email' => [
            // Set time interval to get emails (minutes), default is 30 minutes
            'interval' => 30,

            // Set number of emails to be sent in an interval, default is 4 emails.
            'count'  => 4,
        ],

        // Configure thresholds for resources.
        'thresholds' => [
            // Set the CPU usage threshold (percentage).
            'cpu_usage' => env('MOCKLOGGER_CPU_THRESHOLD', 90),

            // Set the memory usage threshold (percentage).
            'memory_usage' => env('MOCKLOGGER_MEMORY_THRESHOLD', 80),

            // Set the hard disk drive usage threshold (percentage).
            'hard_disk_space' => env('MOCKLOGGER_HDD_THRESHOLD', 80),
        ],
    ],
]
```

To start monitoring your server, run this command:

```
php artisan mocklogger:monitor
```

For continuous monitoring, you can schedule this command with a cron job. Keep your server in check effortlessly with this tool.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

849d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e45be97a0239f8c554646d74684d49de6159af98a343d9392fa8976bfcab878?d=identicon)[Muchwat](/maintainers/Muchwat)

---

Top Contributors

[![Muchwat](https://avatars.githubusercontent.com/u/13133862?v=4)](https://github.com/Muchwat "Muchwat (150 commits)")

---

Tags

httpmiddlewarelaravelloggingdebuggingrequestsresponsesmockloggermocklogger-sdk

### Embed Badge

![Health badge](/badges/moktech-mocklogger-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/moktech-mocklogger-sdk/health.svg)](https://phpackages.com/packages/moktech-mocklogger-sdk)
```

###  Alternatives

[tomschlick/request-migrations

HTTP Request Migrations

1844.5k](/packages/tomschlick-request-migrations)[matthewbdaly/laravel-etag-middleware

A Laravel middleware for adding ETags to HTTP requests to improve response times

64326.0k2](/packages/matthewbdaly-laravel-etag-middleware)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[middlewares/access-log

Middleware to generate access logs

20121.2k2](/packages/middlewares-access-log)[open-southeners/laravel-dto

Integrate data transfer objects into Laravel, the easiest way

101.9k](/packages/open-southeners-laravel-dto)

PHPackages © 2026

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