ums/mikrotik
最新稳定版本:2.4.5
Composer 安装命令:
composer require ums/mikrotik
包简介
A PHP SDK for Mikrotik API
README 文档
README
This PHP SDK provides a convenient interface for interacting with the Mikrotik RouterOS API. You can use this SDK to connect to a Mikrotik device, execute commands, and manage the RouterOS configuration.
Installation
This PHP SDK provides a convenient interface for interacting with the Mikrotik RouterOS API. You can use this SDK to connect to a Mikrotik device, execute commands, and manage the RouterOS configuration.
composer require ums/mikrotik
Usage
To use the SDK, create an instance of the MikrotikSdk class, and then use its methods to connect to a Mikrotik device.
use MikrotikSdk\MikrotikSdk; $mikrotik = new MikrotikSdk; // Connect to Mikrotik $connect = $mikrotik->connect('192.168.88.1', 'admin', 'password'); if ($connect) { echo 'Connected'; } else { echo 'Not Connected'; }
Methods
connect($ip, $username, $password)
Connects to the Mikrotik device using the specified IP address, username, and password. Returns true on successful connection, otherwise false.
$connect = $mikrotik->connect('192.168.88.1', 'admin', 'password');
disconnect()
Disconnects from the Mikrotik device. Returns true on successful disconnection, otherwise false.
$disconnect = $mikrotik->disconnect();
Additional Methods
You can use the following methods to perform various operations on the Mikrotik device:
executeCommand($command, $param2 = true): Executes a RouterOS command. Returns true on success.
$result = $mikrotik->executeCommand('/interface/print');
sendCommand($com, $arr = array()): Sends a custom command with optional parameters. Returns the parsed response.
$response = $mikrotik->sendCommand('/ip/address/print', ['?interface' => 'ether1']);
parseResponse($response): Parses the raw response from RouterOS. Returns an array with parsed data.
$parsedData = $mikrotik->parseResponse($response);
Example
Here's a complete example demonstrating the usage of the SDK:
use MikrotikSdk\MikrotikSdk; $mikrotik = new MikrotikSdk; // Connect to Mikrotik $connect = $mikrotik->connect('192.168.88.1', 'admin', 'password'); if ($connect) { // Execute a command $response = $mikrotik->sendCommand('/ip/address/print', ['?interface' => 'ether1']); // Parse and display the response $parsedData = $mikrotik->parseResponse($response); print_r($parsedData); // Disconnect from Mikrotik $mikrotik->disconnect(); } else { echo 'Not Connected'; }
The ip address, username, and password should be replaced with the actual values of your Mikrotik device.
License
The MIT License (MIT). Please see License File for more information.
Donate to this project
If you find this project useful, please consider making a donation. Any funds donated will be used to help further development on this project.
Credits
-
Nick Barnes
-
[Ben Menking](ben [at] infotechsc [dot] com)
-
[Cristian Deluxe](djcristiandeluxe [at] gmail [dot] com)
-
[Mikhail Moskalev](mmv.rus [at] gmail [dot] com)
References
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## Donate to this project
If you find this project useful, please consider making a donation. Any funds donated will be used to help further development on this project.
[](https://paystack.com/pay/oqwdgv9xck)
ums/mikrotik 适用场景与选型建议
ums/mikrotik 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 108 次下载、GitHub Stars 达 5, 最近一次更新时间为 2024 年 04 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ums/mikrotik 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ums/mikrotik 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 108
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-18