dmsysop/mikrotik-api

Laravel Mikrotik API Wrapper - by JJSquady

dev-master 2019-10-18 16:31 UTC

This package is not auto-updated.

Last update: 2024-04-28 11:03:22 UTC


README

WIP - Work In Progress

Instalation

Via composer:

composer require jjsquady/mikrotikapi

Or manually insert this block into your composer.json in require section:

"require": {
    "jjsquady/mikrotikapi": "dev-master", // <- this line
}

Configuration on Laravel (< 5.4):

Insert into config/app.php in providers array:

dmsysop\MikrotikApi\MikrotikServiceProvider::class

Use the Facade:

Insert into config/app.php in facades array:

'Mikrotik' => dmsysop\MikrotikApi\Facades\MikrotikFacade::class

Note: for Laravel 5.4+ this package comes with Package Discovery enabled.

Publish the configuration file:

php artisan vendor:publish --provider=dmsysop\MikrotikApi\MikrotikServiceProvider::class

Basic Usage:

Set up the host and credentials into .env file:

   MK_API_HOST=<mk_ip>
   MK_API_USER=<username>
   MK_API_PASSWORD=<password>
   MK_API_PORT=<mk_port_defaults_8728>

// create a connection with Mikrotik Router

$conn = Mikrokit::connect()->getConnection();
 
if($conn->isConnected()) {
    // you have access to Commands
    // and can call from here...
}

Getting interfaces:

$conn = Mikrokit::connect()->getConnection();
 
if($conn->isConnected()) {
    // Get all interfaces
    $interfaces = Interfaces::bind($conn)->get();
    
    // get() returns a Collection and you can use all methods available
    
    // you can send it to view 
    return view("<some_view>", [
        'interfaces' => $interfaces
    ]);
}

This project its a work in progress... and its in early developing phase. I really get thankful with ur contribution.

Created by jjsquady (Jorge Junior)
(cc) 2017-2019
License: MIT