anandaerditya/routeros-api-php
Composer 安装命令:
composer require anandaerditya/routeros-api-php
包简介
Mikrotik RouterOS API Communicator Module for PHP
README 文档
README
This library is using API Client Communicator under PHP Socket, thanks to the repository from EvilFreelance. This library provides built-in methods based on the available configuration under Winbox, with their respective commands and parameters. At the moment, this library supports RouterBoard and Cloud Router Switch with pre-6.43 and post-6.43 versions of RouterOS, as mentioned in this repository.
Changelog
1.6.2 ( Enhancement, Feature )
-
Update commands and their parameters into the following methods:
router_switch(),router_switch_port(),router_switch_port_isolation(),
-
Add new methods :
router_switch_rule()
1.5.3 ( Bugfix, Feature )
- Add new methods :
system_resource(),system_resource_cpu(),system_resource_irq(),system_resource_pci(),system_resource_usb(),interface_bridge_calea(),interface_bridge_filter(),
1.5.3 ( Bugfix )
- Add message handler for
!trap,!re,!done, and!fataltype under thesend()method.
1.4.2 ( Bugfix )
- Fix Mikrotik API response message handling under
send()method;
1.3.22 ( Hotfix )
- Add new Exception : ErrorException;
- Add error handler for each method to catch any errors under mikrotik API.
- Add new methods :
ip_dhcp_server_lease()ip_arp()router_switch()router_switch_port()
Requirements
PHP: Version 8.0 and upext-sockets: A Socket extension for PHPRouterOS: pre-6.43 and post-6.43 (Tested on RouterBoard and Cloud Router Switch device)
How to Install
Under composer, just copy this command to begin add this library into your project.
composer require anandaerditya/routeros-api-php
Using the Library
If you are using Composer Project such Laravel Framework, you can just call the library under Erditya\RouterOSInstance class. As follows :
include 'vendor/autoload.php'; use Erditya\RouterOSInstance; $router = new RouterOSInstance(); # Create connection $router = $router->connect( [ 'host' => '192.168.10.1', 'user' => 'username', 'pass' => 'password', 'port' => 8728 ] ); # Example : Fetch all IP Addresses if ($router->is_connected()) { # Get All Addresses var_dump($router->ip_addresses()); # Get address with interface ether2 var_dump($router->ip_addresses(['interface' => 'ether2'])); # Update address item in ID *2 var_dump($router->ip_addresses('set', [ '.id' => '*2', 'comment' => 'Some Comments' ])); }
Or, another way to approach :
include 'vendor/autoload.php'; use Erditya\RouterOSInstance; $router = new RouterOSInstance(); # Create connection $router = $router->connect( [ 'host' => '192.168.10.1', 'user' => 'username', 'pass' => 'password', 'port' => 8728 ] ); # Get All Addresses var_dump($router->ip_addresses()); # Get address with interface ether2 var_dump($router->ip_addresses(['interface' => 'ether2'])); # Update address item in ID *2 var_dump($router->ip_addresses('set', [ '.id' => '*2', 'comment' => 'Some Comments' ]));
Available Methods
List of all methods available in this library at this version :
-
General
connect()is_connected()
-
Interface
interface_bridge()interface_bridge_port()interface_bridge_port()interface_ethernet()interface_list()interface_list_member()interface_vlan()
-
IP
ip_addresses()ip_dhcp_server()ip_dhcp_server_network()ip_dns()ip_firewall_filter()ip_firewall_nat()ip_hotspot_user_profiles()ip_hotspot_users()ip_hotspot_server_profiles()ip_hotspot_servers()ip_hotspot_ip_binding()ip_pool()ip_route()ip_services()
-
System
system_identity()system_user_groups()system_users()
-
Switch (for Cloud Router Switch only)
switch_crs_egress_vlan_tag()switch_crs_mac_based_vlan()switch_crs_port()
Commands & Parameters, and Response
All the methods provided in this library are similar to Winbox's CLI terminal. You can check them under Winbox for more information. All the methods using the command print as the default returned the response as an array. If you call the method using another command, such as add, set, remove, etc., the method will return true, which indicates it was successfully executed.
anandaerditya/routeros-api-php 适用场景与选型建议
anandaerditya/routeros-api-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 361 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 anandaerditya/routeros-api-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anandaerditya/routeros-api-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 361
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-07