PHPackages                             xbnz/mtr - 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. xbnz/mtr

ActiveLibrary

xbnz/mtr
========

Framework agnostic package for MTR

0.1.2(4y ago)010MITPHPPHP 8.1.\*

Since Jan 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/XbNz/mtr)[ Packagist](https://packagist.org/packages/xbnz/mtr)[ RSS](/packages/xbnz-mtr/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (10)Versions (4)Used By (0)

[![GitHub Workflow Status](https://camo.githubusercontent.com/59afeaeaf05ed8abf464799364e93823cc1ab8735511e20408a7d8f773d08f34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f78626e7a2f6c61726176656c2d6d756c74692d69702f52756e25323074657374733f6c6162656c3d5465737473267374796c653d666f722d7468652d6261646765266c6f676f3d6170707665796f72)](https://camo.githubusercontent.com/59afeaeaf05ed8abf464799364e93823cc1ab8735511e20408a7d8f773d08f34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f78626e7a2f6c61726176656c2d6d756c74692d69702f52756e25323074657374733f6c6162656c3d5465737473267374796c653d666f722d7468652d6261646765266c6f676f3d6170707665796f72)

PHP MTR
=======

[](#php-mtr)

### Framework-agnostic asynchronous MTR library

[](#framework-agnostic-asynchronous-mtr-library)

⚠️ The MTR command requires root privileges for low interval, edit your /etc/sudoers file.Get up and running
==================

[](#get-up-and-running)

Require the package
-------------------

[](#require-the-package)

`composer require xbnz/mtr`

Using MTR in your project (Laravel)
-----------------------------------

[](#using-mtr-in-your-project-laravel)

```
// Optionally configure DI (Laravel example)

class AppServiceProvider extends Provider
{
    public function register()
    {
        $this->app->bind(MTR::class, function (Application $app) {
            return MTR::build(Config::get('services.mtr_options'), $app->make(LoggerInterface::class));
        });
    }
}
```

MTR options
-----------

[](#mtr-options)

```
// services.php
return [
    // ...
    'mtr_options' => new \Xbnz\Mtr\MtrOptionsConfigDto(...)
]
```

⚠️ Important note on configuration options.You should not disable the 'report wide' or 'json' options. The package will cease to work.

Bulk or single IP with async execution
--------------------------------------

[](#bulk-or-single-ip-with-async-execution)

```
use Xbnz\Mtr;

public function __construct(private MTR $mtr)
{}

// Or without DI...

public function __construct()
{
    $this->mtr = Mtr::build(new MtrOptionsConfigDto(...), new Logger);
}

public function example()
{

    // Consider a high timeout value for large scans.
    // Async threads above 50 might cause inaccuracies in RTT statistics.

    $results = $this->mtr->withIp('1.1.1.1', '8.8.8.8')->wrap($consoleTimeout, $concurrentProcesses);
    // OR
    $results = $this->mtr->withIp(...['1.1.1.1', '8.8.8.8'])->wrap($consoleTimeout, $concurrentProcesses);
    // OR
    $results = $this->mtr->withIp('1.1.1.1')->wrap($consoleTimeout, $concurrentProcesses);
    // OR
    $results = $this->mtr->withIp(995738574453)->wrap($consoleTimeout, $concurrentProcesses);
    // OR
    $results = $this->mtr->withIp('google.com')->wrap($consoleTimeout, $concurrentProcesses);
    // OR
    $results = $this->mtr->withIp(0x1294812)->wrap($consoleTimeout, $concurrentProcesses);

    Assert::containsOnlyInstancesOf(
        MtrResult::class,
        $results
    );

    /**
    * If last hop of MTR !== supplied IP, the target is dead.
    * In most circumstances, you'd want to reject dead targets.
    * You might still want to see the hops for a dead target, so the default policy is not to reject.
    */
    $aliveTargetHopPairs = $results
        ->reject(fn($result) => $result->targetDown())
        ->map(fn($result) => [$result->targetHost => $result->hops]);
        ->each(fn($targetWithHops) => Assert::containsOnlyInstancesOf(MtrHopDto::class, $targetWithHops));

    $aliveTargetHopPairs
        ->each(function ($hops, $ip) {
            if ($hops->last()->packetLoss > 5) {
                $this->logger->log("Target {$ip}, hop {$hops->last()->hopPositionCount} has {$hops->last()->packetLoss}% loss")
            }
        });
}
```

Hooking into the `raw()` method
-------------------------------

[](#hooking-into-the-raw-method)

The `raw()` method will return an unprocessed result set from MTR. This will also allow you to hook into each asynchronous process, which is useful for long-running processes.

For example, you might want to keep track of each IP that is processed, like so.

```
public function handle(MTR $mtr)
{
    // Thousands of IPs
    $mtr->withIp('1.1.1.1/20')
        ->raw(callable: function (ForkSerializableProcessDto $dto) {
            dump($dto->host . PHP_EOL);
        })
}
```

###  Health Score

22

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~1 days

Total

3

Last Release

1510d ago

### Community

Maintainers

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

---

Top Contributors

[![XbNz](https://avatars.githubusercontent.com/u/12668624?v=4)](https://github.com/XbNz "XbNz (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xbnz-mtr/health.svg)

```
[![Health](https://phpackages.com/badges/xbnz-mtr/health.svg)](https://phpackages.com/packages/xbnz-mtr)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.5M596](/packages/sylius-sylius)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k25.2M1.6k](/packages/infection-infection)[phpdocumentor/phpdocumentor

Documentation Generator for PHP

4.4k3.1M803](/packages/phpdocumentor-phpdocumentor)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M125](/packages/sulu-sulu)[humbug/box

Fast, zero config application bundler with PHARs.

1.3k774.5k54](/packages/humbug-box)[webmozarts/console-parallelization

Enables parallelization of Symfony Console commands

2283.5M5](/packages/webmozarts-console-parallelization)

PHPackages © 2026

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