Looking to hire Laravel developers? Try LaraJobs

laravel-mikrotik-api-ros6 maintained by mivodev

Description
Laravel wrapper for mivodev/mikrotik-api-ros6. Provides ServiceProvider, Facade, and config.
Author
Last update
2026/05/28 10:27 (dev-main)
License
Downloads
1

Comments
comments powered by Disqus

Laravel Mikrotik API ROS6

Laravel Mikrotik API ROS6

PHP Version Laravel Version License

A clean, elegant Laravel wrapper for mivodev/mikrotik-api-ros6. Provides a ServiceProvider, Facade, and configuration file for seamless integration into your Laravel application.

Installation

composer require mivodev/laravel-mikrotik-api-ros6

Publish the configuration file:

php artisan vendor:publish --tag=mikrotik-ros6-config

Configuration

After publishing, you can configure your default router credentials in your .env file:

MIKROTIK_ROS6_HOST=192.168.1.1
MIKROTIK_ROS6_USERNAME=admin
MIKROTIK_ROS6_PASSWORD=rahasia
MIKROTIK_ROS6_PORT=8728
MIKROTIK_ROS6_SSL=false
MIKROTIK_ROS6_TIMEOUT=3
MIKROTIK_ROS6_ATTEMPTS=5

Usage

Use the MikrotikRos6 facade to easily communicate with your routers anywhere in your Laravel app.

Using Default Connection

By default, the Facade uses the connection defined in .env.

use Mivo\LaravelMikrotikRos6\Facades\MikrotikRos6;

// Execute commands on the default router
$users = MikrotikRos6::comm('/ip/hotspot/user/print');

Hybrid Multi-Tenant Connections

For SaaS platforms like Mivo Enterprise, you don't store router credentials in .env. Instead, you retrieve them dynamically from your database. The Manager supports passing an array directly to establish a dynamic, cached connection:

use App\Models\Router;
use Mivo\LaravelMikrotikRos6\Facades\MikrotikRos6;

$router = Router::find(1);

// Build connection dynamically from database model
$client = MikrotikRos6::connection([
    'host'     => $router->vpn_assigned_ip,
    'username' => $router->api_username,
    'password' => $router->api_password,
    'port'     => 8728,
]);

// Execute command on that specific router
$activeUsers = $client->comm('/ip/hotspot/active/print');

// Disconnect from the specific router
$client->disconnect();

Advanced Examples

See the core package documentation for full usage of the comm() method, including filtering, regex, and error handling.

License

MIT License. See LICENSE for details.