imafaz/mikrolink
Composer 安装命令:
composer require imafaz/mikrolink
包简介
lightweight library for manage mikrotik router os with api
README 文档
README
MikroLink is a lightweight PHP library designed for interacting with MikroTik routers using their API. This library simplifies the process of managing and automating tasks on MikroTik devices programmatically.
Requirements
To utilize this library effectively, ensure your environment meets the following requirements:
- PHP version 7.0 or higher
Installation
For seamless installation, use Composer:
composer require imafaz/mikrolink
Quick Start
Once the library is installed, include it in your PHP script:
require_once 'vendor/autoload.php'; use MikrotikApi\MikroLink;
Usage
Initialize the MikroLink object with debug mode, timeout, attempts, and delay settings:
$router = new MikroLink;
Connect to a MikroTik router using its IP, username, password, port, and optional SSL mode:
$router->connect('192.168.1.1', 'admin', 'password', 8728, false);
Execute commands on the connected router:
$response = $router->exec('/interface/print'); var_dump($response); //print array response
disconnect router connection :
$router->disconnect();
Available Methods
__construct
Description:
Initializes the MikroLink object with debugging and connection settings.
Signature:
$router = new MikroLink( int $timeout = 1, int $attempts = 3,int $delay = 0,$logFile = 'mikrolink.log',$printLog = false);
Attributes:
| Attribute | Description | Type | Required | Default |
|---|---|---|---|---|
| $timeout | Connection timeout (seconds) | int | No | 1 |
| $attempts | Connection attempts | int | No | 3 |
| $delay | Delay between attempts (sec) | int | No | 0 |
| $logFile | log file name | string | No | mikrolink.log |
| $printLog | print log | bool | No | false |
connect
Description:
Connects to a MikroTik router using the provided credentials and connection details.
Signature:
$router->connect(string $ip, string $username, string $password, int $port, $ssl = false);
Attributes:
| Attribute | Description | Type | Required | Default |
|---|---|---|---|---|
| $ip | Router IP address | string | Yes | N/A |
| $username | Router login username | string | Yes | N/A |
| $password | Router login password | string | Yes | N/A |
| $port | Router API port | int | Yes | N/A |
| $ssl | SSL mode toggle | bool | No | false |
exec
Description:
Executes a MikroTik API command with optional parameters.
Signature:
$router->exec(string $command, array $params = null);
Attributes:
| Attribute | Description | Type | Required | Default |
|---|---|---|---|---|
| $command | API command to execute | string | Yes | N/A |
| $params | Additional command parameters | array | No | null |
disconnect
Description:
Terminates the connection with the MikroTik router.
Signature:
$router->disconnect();
License
This library is licensed under the MIT License
imafaz/mikrolink 适用场景与选型建议
imafaz/mikrolink 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mikrotik」 「imafaz」 「MikroLink」 「mikrotik api」 「api mikrotik」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 imafaz/mikrolink 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imafaz/mikrolink 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 imafaz/mikrolink 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Client API for RouterOS/Mikrotik
Mikrotik API PHP Library for working with RouterOS API 2019
Client API for RouterOS/Mikrotik
Complete, universal PHP client for Mikrotik RouterOS v7 REST API. Framework-agnostic, zero-dependency.
Complete, universal PHP client for Mikrotik RouterOS v6 API (Socket Protocol Port 8728). Framework-agnostic, zero-dependency.
Laravel wrapper for mivodev/mikrotik-api-ros7. Provides ServiceProvider, Facade, and config.
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-03