Download the PHP package bennito254/routeros-client without Composer
On this page you can find all versions of the php package bennito254/routeros-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bennito254/routeros-client
More information about bennito254/routeros-client
Files in bennito254/routeros-client
Package routeros-client
Short Description A modern, production-grade PHP client for MikroTik RouterOS API.
License MIT
Informations about the package routeros-client
RouterOS Client
A modern, production-grade PHP client for communicating with the MikroTik RouterOS API over raw sockets. Built for modern PHP 8.2+ with PSR-4 autoloading, strong typing, robust error handling, and proxy support out-of-the-box.
Features
- Modern Architecture: Clean object-oriented design, completely uncoupled from heavy libraries.
- Direct Sockets: Communicates natively using raw TCP sockets, fully implementing the RouterOS length-encoded protocol. No cURL needed.
- Proxy Support built-in: First-class support for routing connections through SOCKS5 and HTTP CONNECT proxies. Handshake is performed natively.
- TLS/SSL encryption: Support for API-SSL with options to configure certificates and peer verification.
- Query Builder: Fluent
Querybuilder for crafting RouterOS commands and filters easily. - Collections: Responses are encapsulated in
ResponseCollectioncontainingResponseSentenceobjects. - Service Facades: Ready-to-use Facade classes to manage IP addresses, Hotspot clients, and PPP accounts fluently.
- Laravel Integration: Out-of-the-box support for Laravel with zero configuration required, complete with a service provider, facade, and published config.
Installation
Install via Composer:
Basic Usage
Laravel Integration
The package automatically discovers its Laravel service provider and registers itself. You can easily publish the configuration file to customize your connection settings:
Once published to config/routeros.php, update your .env file:
You can then utilize the Laravel RouterOS Facade anywhere in your application:
Service Facades
The package provides dedicated Service Facades allowing you to rapidly query, add, modify, or toggle states on RouterOS entities (such as IP Addresses, Hotspot Users, and PPP Secrets) without manually constructing queries.
The available built-in Facades under Bennito254\RouterOS\Facade\ are:
IpAddress(/ip/address)HotspotUser(/ip/hotspot/user)HotspotActive(/ip/hotspot/active)PppSecret(/ppp/secret)PppActive(/ppp/active)
Using the Query Builder
Connecting Through a Proxy
Connect to your Mikrotik behind a restrictive network using a SOCKS5 proxy:
You can also use an HTTP CONNECT proxy by changing type to 'http'.
Connecting via API-SSL
Enable SSL to connect securely using the API-SSL port (default 8729).
Error Handling
The package provides a robust exception hierarchy under Bennito254\RouterOS\Exception:
ConnectionException: Network issues, timeouts, and socket errors.AuthenticationException: Invalid credentials.ProxyException: Errors during SOCKS5 or HTTP CONNECT handshake.ProtocolException: Corrupted length encoding or malformed sentences.TrapException: Errors returned by RouterOS (!trap).FatalException: Fatal errors from RouterOS (!fatal).
Example: