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

1. Go to this page and download the library: Download mivodev/laravel-mikrotik-api-ros7 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-ros7 example snippets


use Mivo\LaravelMikrotikRos7\Facades\MikrotikRos7;

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

// 2. PPPoE Secret Management (REST GET / DELETE / POST)
$activeSessions = MikrotikRos7::pppoe()->getActive();
MikrotikRos7::pppoe()->disconnect('customer_123'); // Disconnects session by REST GET lookup + DELETE /rest/ppp/active/{.id}

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

// 4. Dual-Stack IPv4 / IPv6 Support (REST endpoints)
MikrotikRos7::ipAddress()->addV6('2001:db8::1/64', 'ether1'); // REST PUT to /rest/ipv6/address
MikrotikRos7::firewall()->addV6AddressList('blocked', '2001:db8::2'); // REST PUT to /rest/ipv6/firewall/address-list

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

use App\Models\Router;
use Mivo\LaravelMikrotikRos7\Facades\MikrotikRos7;

$router = Router::find(1);

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

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