PHP code example of mivodev / laravel-mikrotik-api-ros6

1. Go to this page and download the library: Download mivodev/laravel-mikrotik-api-ros6 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mivodev / laravel-mikrotik-api-ros6 example snippets


use Mivo\LaravelMikrotikRos6\Facades\MikrotikRos6;

// 1. Hotspot Management
$users = MikrotikRos6::hotspot()->getUsers();
MikrotikRos6::hotspot()->addUser([
    'name' => 'dyzulk',
    'password' => 'secret123',
    'profile' => 'Premium-1M'
]);

// 2. PPPoE Secret Management
$activeSessions = MikrotikRos6::pppoe()->getActive();
MikrotikRos6::pppoe()->disconnect('customer_123'); // Disconnects session by print-lookup + remove

// 3. Simple Queues (Bandwidth Limiting)
MikrotikRos6::queue()->addSimpleQueue([
    'name' => 'customer_123_limit',
    'target' => '192.168.88.10',
    'max-limit' => '1M/2M'
]);

// 4. Dual-Stack IPv4 / IPv6 Support
MikrotikRos6::ipAddress()->addV6('2001:db8::1/64', 'ether1'); // IPv6 Address assignment
MikrotikRos6::firewall()->addV6AddressList('blocked', '2001:db8::2'); // IPv6 address list isolation

$users = MikrotikRos6::query('/ip/hotspot/user/print')
    ->where('profile', 'Premium-1M')
    ->whereRegex('name', '^dyzulk')
    ->select(['name', 'limit-uptime'])
    ->get();

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

$router = Router::find(1);

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

// Use any service manager on this specific router
$users = $client->hotspot()->getUsers();
bash
php artisan vendor:publish --tag=mikrotik-ros6-config
bash
php artisan mivo:ros6-ping --help