evilfreelancer/routeros-api-php
A modern PHP client for the MikroTik RouterOS API. Connect to RouterOS 6 and 7 devices, run commands, and parse responses through a clean, framework-agnostic, object-oriented interface. Install via Composer and use it in Laravel or any PHP project.
Architecture fit
evilfreelancer/routeros-api-php is a framework-agnostic Composer library, not a Laravel package. It speaks the MikroTik RouterOS binary API (sentence-based protocol on TCP 8728 / API-SSL 8729) and ships two client generations: a legacy RouterOS\Client and a newer query-builder client. Architecturally it belongs at the infrastructure edge of the Laravel app — behind a RouterOsGateway interface (or repository), consumed by jobs/services, with the library itself never leaking into domain code. Fit is strong only where MikroTik is a first-class part of the estate (WISP/ISP provisioning, PPPoE/hotspot subscriber management, CPE fleet config, bandwidth scripting). Where RouterOS is peripheral, the cost of owning an unabstracted socket client outweighs the benefit.
Integration feasibility Composer-installable, PSR-4, PSR-3 logger injection, array-based config. It has no Laravel service provider, no auto-discovery, no publishable config, no facade — all glue is ours. That is a one-off 1–3 day build (provider + config + lazy singleton connection + health check), not a blocker. The 1.7.0 content is three targeted fixes and no API surface change, so integration effort is unchanged from 1.6.0.
Technical risk
parseResponse throwing on empty payloads for nested :execute-style scripts. This was a real production failure class for anyone driving RouterOS scripting rather than plain commands; the fix materially improves reliability of the scripting path.Key questions
parseResponse fix covered by a regression test, and does it distinguish "legitimately empty" from "truncated frame"?Stack fit
Target PHP 8.2–8.4 with Laravel 10/11/12. Bind the client as a lazily-constructed singleton in a small RouterOsServiceProvider, with a config/routeros.php covering host, port, username, password, TLS toggle, connect/read timeouts, and logging channel. Expose only narrow, typed methods on our gateway (provisionSubscriber, setQueue, runScript, fetchActiveSessions) so the library is swappable. Never resolve the client in a controller — dispatch a job.
Migration path
fetchActiveSessions/interface stats into a dashboard behind a flag. No writes. Validates auth, TLS, and timeout behaviour under real latency..env.Compatibility
Pin ^1.7.0 and commit the lockfile. Verify against the RouterOS firmware versions actually deployed, not just latest — the API differs meaningfully between v6.4x and v7. Confirm PHP 8.4 locally and in CI; the timeout fix is the whole point of this bump, so it must be exercised. Re-run the Windows developer setup (per PR #142) before anyone rebases onto 1.7.0.
Sequencing Bump dependency → review dev-dependency lockfile diff → run gateway contract tests against CHR → confirm the three fix areas explicitly (timeout, empty nested script, Windows dev) → staging with production-shaped latency → production behind a feature flag → delete the 1.6.x fallback after one stable week.
Maintenance Low upstream churn (three PRs in this cycle), but we own the Laravel wrapper, the config schema, and the gateway interface — that is our permanent surface, not theirs. Budget roughly one day per quarter for dependency bumps plus a re-test against the current RouterOS release. Track upstream issues #131 and #136 as closed so we can drop any local workarounds.
Support The dominant support ticket will remain "router unreachable / request hung." 1.7.0 improves the library's timeout behaviour, but first-line triage still needs: is the socket reachable, are credentials valid and in an API-permitted group, is the router's API service enabled on the expected port. Publish a runbook. Because two of the three fixes come from first-time contributors, treat 1.7.0 as a normal-risk dependency bump rather than a trust signal — regression-test rather than assume.
Scaling Each command occupies one TCP connection, and RouterOS serialises work per connection; concurrency means multiple connections, not multiplexing. For fleets in the hundreds-to-thousands, run provisioning through dedicated queue workers with per-router rate limiting and backoff, cap worker pool size so a router outage cannot exhaust the queue, and keep read-polling on a schedule rather than per-request. Throughput is bounded by the router, not by Laravel — size expectations accordingly.
Failure modes
Ramp-up
Expect 2–4 engineer-days for a mid-level Laravel developer to be productive, plus a hard dependency on someone with RouterOS CLI literacy (groups, services, /export, scripting). Two docs are non-negotiable before Phase 2: the gateway interface reference and an incident runbook for hung/unreachable routers. The library's API is simple; the operational knowledge is the actual learning curve.
Recommendation Adopt 1.7.0. It is a low-risk, non-breaking bump that closes three observed field issues — the PHP 8.4 timeout and nested-script empty-response fixes are directly relevant to production stability, and the Windows fix removes a developer-experience divergence. Treat it as the baseline assessment for this dependency: no Laravel-native integration exists, so the wrapper is ours to own and document.
How can I help you explore Laravel packages today?