[PHP/Laravel] zilleali/mikrotik-laravel - Open Source RouterOS API package

Hello MikroTik community,

I want to share an open-source PHP/Laravel package I just released for RouterOS API integration.

GitHub: GitHub - Zilleali/mikrotik-laravel: MikroTik RouterOS API for Laravel - PPPoE, Hotspot, Queues & Monitoring ยท GitHub
Packagist: https://packagist.org/packages/zilleali/mikrotik-laravel

Install with one command:
composer require zilleali/mikrotik-laravel


WHAT IT DOES:

The package wraps the RouterOS API into clean, organized Laravel service classes. Instead of writing raw API sentences, you get a clean PHP interface:

// PPPoE
$sessions = MikroTik::pppoe()->getActiveSessions();
MikroTik::pppoe()->kickSession('user1');
MikroTik::pppoe()->bulkDisable(['user1', 'user2']);

// System health
$cpu = MikroTik::system()->getCpuLoad();
$uptime = MikroTik::system()->getUptime();

// Wireless
$clients = MikroTik::wireless()->getRegistrationTable();

// Queue
MikroTik::queue()->setLimit('user1', '10M', '10M');
MikroTik::queue()->bulkSetLimit($users);

// Firewall
MikroTik::firewall()->addToAddressList('1.2.3.4', 'blocked');

// WireGuard
MikroTik::vpn()->getWireGuardPeers();
MikroTik::vpn()->addWireGuardPeer([...]);


MANAGERS INCLUDED (12 total):

  • PppoeManager โ€” secrets, profiles, active sessions, bulk kick/enable/disable
  • HotspotManager โ€” users, profiles, active hosts, voucher generation
  • QueueManager โ€” simple/tree queues, bulk bandwidth limits
  • FirewallManager โ€” filter rules, NAT, mangle, address lists
  • SystemManager โ€” resources, health (temp/voltage), logs, ping, reboot
  • InterfaceManager โ€” status, traffic monitoring, VLANs
  • DhcpManager โ€” leases, static assignments
  • WirelessManager โ€” registration table, access list
  • IpPoolManager โ€” pool ranges, used address tracking
  • RadiusManager โ€” RADIUS servers, CoA incoming config
  • RouterUserManager โ€” Winbox/SSH/API users, groups
  • VpnManager โ€” WireGuard peers, L2TP sessions, PPTP sessions

TECHNICAL DETAILS:

  • Implements RouterOS sentence protocol (variable-length encoding)
  • Supports RouterOS v6.43+ plain login AND legacy MD5 challenge-response
  • Multi-router support โ€” manage multiple routers from one app
  • Caching layer โ€” reduces API calls on production hardware
  • Retry mechanism โ€” configurable attempts + delay
  • Laravel Events for session connect/disconnect/router-down
  • Artisan commands: mikrotik:ping, mikrotik:sync, mikrotik:monitor
  • 70+ unit tests, CI on PHP 8.2/8.3 x Laravel 11/12

WHY I BUILT THIS:

I'm a network engineer (MTCNA certified) building NexaLink โ€” an ISP management SaaS for MikroTik-based ISPs. I needed a reliable RouterOS API layer for Laravel. After building it, I packaged it properly and released it as open source.

Tested on:

  • hAP acยฒ (RBD52G)
  • RouterOS 7.14.3
  • RouterOS 6.49.x

FEEDBACK WELCOME:

If you find bugs, RouterOS version incompatibilities, or missing features โ€” please open an issue on GitHub. PRs are very welcome.

Specially interested in feedback from engineers running:

  • CCR series (high session counts)
  • RouterOS 7.x (newer API behaviors)
  • Large IP pools (1000+ PPPoE users)

Zill E Ali
MTCNA Certified | Zilleali (ZILLEALI) ยท GitHub

this is NOT one newsletter.

Yes I know I did it by mistake.

can build use freeradius sir @zilleali ..?

@horasjey Sorry for the late reply. Yes, I'm also customising FreeRadius V3.0

Update: v1.6.0 โ€” 72 installs, 4 stars

Quick changelog since the original post (skipping the noise; this is the stuff that matters if you're running this in production):

Reliability

  • Fixed a bug in multi-row query() parsing โ€” large result sets (e.g. getActiveSessions() on routers with hundreds of PPPoE users) could misalign rows. Fixed in v1.6.0 by using sentence-terminating empty words as proper row delimiters.

  • All managers now throw instead of failing silently (ResourceNotFoundException, InvalidRouterResponseException), and input is validated before it ever reaches the socket.

  • PHPStan level 5, zero errors.

New managers (12 โ†’ 22)
Bridge, IpAddress, Arp, Dns, Route, Ntp, Script, Syslog, plus SessionMonitor, UsageTracker, and RateLimiter for combined PPPoE/Hotspot session tracking and API throttling.

Other

  • TLS connections on port 8729 (self-signed + strict CA)

  • ConnectionPool for persistent multi-router connections with health checks

  • Laravel 13 support

  • Centralized logging (MikrotikLogger) across every manager

GitHub: https://github.com/Zilleali/mikrotik-laravel
Packagist: https://packagist.org/packages/zilleali/mikrotik-laravel

Still very interested in real-world feedback from anyone running CCR-series hardware with high session counts - the v1.6.0 parsing fix should help there specifically, but more testing data is welcome.