PHPackages                             theihasan/dual-agent - 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. [Database &amp; ORM](/categories/database)
4. /
5. theihasan/dual-agent

ActiveLibrary[Database &amp; ORM](/categories/database)

theihasan/dual-agent
====================

Dual agent monitoring for Laravel Nightwatch with database storage

v0.1.2(7mo ago)1301MITPHPPHP ^8.2

Since Sep 29Pushed 7mo agoCompare

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

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

Dual Agent for Laravel Nightwatch
=================================

[](#dual-agent-for-laravel-nightwatch)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4f433b5dd6eecb3a26bfb5c9f0560a24da93c04864d21498b860726dc9d3cbe5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74686569686173616e2f6475616c2d6167656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/theihasan/dual-agent)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8560961a9b16c61a9edcdfe18647fb227239e9da104b8aaa62c3ac97cf3e388d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74686569686173616e2f6475616c2d6167656e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/theihasan/dual-agent/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/12d9a23dafa5eaa8bf1363bd70c5dd9100dcc79304f916e3fa353f4e3bf138ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74686569686173616e2f6475616c2d6167656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/theihasan/dual-agent)[![License](https://camo.githubusercontent.com/2f26136d639c20ed49b8c37ba8873bdf444df14fa5c60e5bdef3599627eb208e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74686569686173616e2f6475616c2d6167656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/theihasan/dual-agent)

Dual Agent is a Laravel package that automatically saves all Nightwatch monitoring data to your application's database while maintaining full compatibility with the original Nightwatch service.

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

[](#requirements)

- PHP 8.2+
- Laravel 10.0+
- [Laravel Nightwatch](https://nightwatch.laravel.com) installed and configured with sampling rates set appropriately

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

[](#installation)

1. Install the package:

    ```
    composer require theihasan/dual-agent
    ```
2. Add service providers (after Nightwatch):

    **For Laravel 10:**Add to `config/app.php`:

    ```
    'providers' => [
        // ...
        \Laravel\Nightwatch\NightwatchServiceProvider::class,
        \Ihasan\DualAgent\DualAgentServiceProvider::class,
        // ...
    ],
    ```

    **For Laravel 11+:**Add to `bootstrap/app.php`:

    ```
    'providers' => [
        \Laravel\Nightwatch\NightwatchServiceProvider::class,
        \Ihasan\DualAgent\DualAgentServiceProvider::class,
    ]
    ```
3. Configure your `.env` file:

    ```
    # Nightwatch Configuration
    NIGHTWATCH_ENABLED=true
    NIGHTWATCH_TOKEN=your-nightwatch-token
    NIGHTWATCH_REQUEST_SAMPLE_RATE=1.0
    NIGHTWATCH_COMMAND_SAMPLE_RATE=1.0
    NIGHTWATCH_EXCEPTION_SAMPLE_RATE=1.0

    # Dual Agent Configuration
    DUAL_AGENT_ENABLED=true
    DUAL_AGENT_AUTO_CONFIGURE=true
    ```
4. Run the installer:

    ```
    php artisan dual-agent:install
    ```

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

[](#configuration)

VariableDefaultDescription`DUAL_AGENT_ENABLED``true`Enable/disable database storage`DUAL_AGENT_AUTO_CONFIGURE``true`Auto-configure when Nightwatch detected`DUAL_AGENT_BUFFER_SIZE``100`Records to buffer before database insert`DUAL_AGENT_REQUEST_SAMPLE_RATE``1.0`Sampling rate for requests (0.0-1.0)`DUAL_AGENT_QUERY_SAMPLE_RATE``0.1`Sampling rate for database queries`DUAL_AGENT_EXCEPTION_SAMPLE_RATE``1.0`Sampling rate for exceptions`DUAL_AGENT_JOB_SAMPLE_RATE``0.5`Sampling rate for queue jobs`DUAL_AGENT_LOG_SAMPLE_RATE``0.01`Sampling rate for log entries`DUAL_AGENT_CLEANUP_ENABLED``true`Enable automatic data cleanup`DUAL_AGENT_RETENTION_DAYS``30`Days to retain metrics data`DUAL_AGENT_AGGREGATION_ENABLED``true`Enable metric aggregationType Safety
-----------

[](#type-safety)

This package includes a comprehensive PHPStan configuration for maximum type safety. The configuration is set to level 9 with strict rules enabled.

### Running Type Analysis

[](#running-type-analysis)

```
# Run PHPStan analysis
composer run phpstan

# Generate baseline for existing issues
composer run phpstan:baseline

# Clear PHPStan cache
composer run phpstan:clear

# Run type checking and tests together
composer run test:all
```

### Configuration Files

[](#configuration-files)

- `phpstan.neon` - Main PHPStan configuration with strict type checking
- `phpstan-baseline.neon` - Baseline file for managing existing issues

The configuration includes:

- **Level 9 strictness** with all strict rules enabled
- **Laravel-specific ignores** for dynamic methods and facades
- **Type coverage requirements** for all methods and properties
- **Dead code detection** for unused private methods and properties
- **Strict comparison rules** to prevent type coercion issues
- **Missing type hints detection** for all parameters and return types

Basic Usage
-----------

[](#basic-usage)

Query your monitoring data using the provided models:

```
use Ihasan\DualAgent\Models\DualAgentMetric;

// Get today's requests
$requests = DualAgentMetric::requests()->today()->get();

// Find slow requests
$slowRequests = DualAgentMetric::slowRequests(1000)->get();

// Get recent exceptions
$exceptions = DualAgentMetric::exceptions()->latest()->limit(10)->get();
```

See full documentation for more query examples and available scopes.

Common Issues
-------------

[](#common-issues)

### Data Not Appearing

[](#data-not-appearing)

Ensure Nightwatch sampling rates are set appropriately in your `.env`:

```
NIGHTWATCH_REQUEST_SAMPLE_RATE=1.0
NIGHTWATCH_COMMAND_SAMPLE_RATE=1.0
NIGHTWATCH_EXCEPTION_SAMPLE_RATE=1.0

```

### Installation Fails

[](#installation-fails)

Make sure Laravel Nightwatch is installed first:

```
composer require laravel/nightwatch
php artisan migrate
```

Links to Full Documentation
---------------------------

[](#links-to-full-documentation)

- [Complete Documentation](documentation.md)

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

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for recent changes.

Security
--------

[](#security)

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

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Ihasan](https://github.com/theihasan)
- Built for [Laravel Nightwatch](https://nightwatch.laravel.com)
- Inspired by the Laravel community

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance64

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Total

2

Last Release

220d ago

### Community

Maintainers

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

---

Top Contributors

[![theihasan](https://avatars.githubusercontent.com/u/142471724?v=4)](https://github.com/theihasan "theihasan (29 commits)")

---

Tags

laravelmonitoringdatabaseMetricsnightwatch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/theihasan-dual-agent/health.svg)

```
[![Health](https://phpackages.com/badges/theihasan-dual-agent/health.svg)](https://phpackages.com/packages/theihasan-dual-agent)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[tpetry/laravel-query-expressions

Database-independent Query Expressions as a replacement to DB::raw calls

357436.5k2](/packages/tpetry-laravel-query-expressions)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[illuminatech/config

Provides support for Laravel application runtime configuration managed in persistent storage

14921.0k1](/packages/illuminatech-config)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[vectorial1024/laravel-cache-evict

Efficiently remove expired Laravel file/database cache data

5813.2k](/packages/vectorial1024-laravel-cache-evict)

PHPackages © 2026

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