Skip to content
ZILLEALI edited this page May 26, 2026 · 1 revision

v1.4.0 — PHPStan & Better Exceptions

Released: 2026-05-26
Tag: v1.4.0
Install: composer require zilleali/mikrotik-laravel:^1.4.0


Overview

Developer experience release — adds PHPStan level 5 static analysis and detailed exception factory methods with actionable error messages.


What's New

1. PHPStan Level 5

Zero errors at PHPStan level 5 — added to CI pipeline.

./vendor/bin/phpstan analyse src --level=5

What was fixed:

  • MikroTik Facade — all use statements added
  • @method docblocks — correct namespaces

2. ConnectionException Factory Methods

Before:

throw new ConnectionException("Failed to connect after 3 attempt(s): Connection refused");

After — actionable messages:

// Unreachable host
throw ConnectionException::unreachable('192.168.1.1', 8728, 'main', 'Connection refused');
// "Cannot connect to router 'main' at 192.168.1.1:8728 — Connection refused"

// Wrong credentials
throw ConnectionException::authenticationFailed('192.168.1.1', 8728, 'admin', 'main');
// "Authentication failed for user 'admin' on router 'main' (192.168.1.1:8728). Check username and password."

// Timeout
throw ConnectionException::timeout('192.168.1.1', 8728, 10, 'main');
// "Connection to router 'main' (192.168.1.1:8728) timed out after 10 seconds."

// Router not in config
throw ConnectionException::routerNotFound('branch');
// "Router 'branch' not found in config/mikrotik.php routers array. Add it under 'routers' key."

// All retries failed
throw ConnectionException::retriesExhausted('192.168.1.1', 8728, 3, 'main', $previous);
// "Failed to connect to router 'main' (192.168.1.1:8728) after 3 attempt(s)."

Exception properties:

try {
    MikroTik::pppoe()->getActiveSessions();
} catch (ConnectionException $e) {
    $e->getHost();   // '192.168.1.1'
    $e->getPort();   // 8728
    $e->getRouter(); // 'main'
    $e->getMessage(); // Full message
}

3. ApiException Factory Methods

// From RouterOS !trap response
throw ApiException::fromTrap('/ppp/secret/add', [
    'message'  => 'already have such entry',
    'category' => '2',
]);
// "RouterOS API error on command '/ppp/secret/add': already have such entry"

// Permission denied
throw ApiException::permissionDenied('/system/reboot', 'monitor');
// "Permission denied for user 'monitor' on command '/system/reboot'. Check RouterOS user group policies."

// Not found
throw ApiException::notFound('/ppp/secret/set', 'user1');
// "Item 'user1' not found via command '/ppp/secret/set'."

Exception properties:

try {
    MikroTik::pppoe()->createSecret([...]);
} catch (ApiException $e) {
    $e->getCommand();  // '/ppp/secret/add'
    $e->getCategory(); // '2'
    $e->getDetail();   // additional detail
}

No Breaking Changes

All existing code works without modification.

composer update zilleali/mikrotik-laravel

v1.3.0 | Managers Reference →


📝 Found an error or missing info?
Edit this page or open an issue to suggest improvements.

Clone this wiki locally