承接 anandaerditya/routeros-api-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anandaerditya/routeros-api-php

Composer 安装命令:

composer require anandaerditya/routeros-api-php

包简介

Mikrotik RouterOS API Communicator Module for PHP

README 文档

README

Static Badge Packagist Version GitHub Release

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 )

  1. Update commands and their parameters into the following methods:

    • router_switch(),
    • router_switch_port(),
    • router_switch_port_isolation(),
  2. Add new methods :

    • router_switch_rule()

1.5.3 ( Bugfix, Feature )

  1. 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 )

  1. Add message handler for !trap, !re, !done, and !fatal type under the send() method.

1.4.2 ( Bugfix )

  1. Fix Mikrotik API response message handling under send() method;

1.3.22 ( Hotfix )

  1. Add new Exception : ErrorException;
  2. Add error handler for each method to catch any errors under mikrotik API.
  3. Add new methods :
    • ip_dhcp_server_lease()
    • ip_arp()
    • router_switch()
    • router_switch_port()

Requirements

  • PHP : Version 8.0 and up
  • ext-sockets : A Socket extension for PHP
  • RouterOS : 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 :

  1. General

    • connect()
    • is_connected()
  2. Interface

    • interface_bridge()
    • interface_bridge_port()
    • interface_bridge_port()
    • interface_ethernet()
    • interface_list()
    • interface_list_member()
    • interface_vlan()
  3. 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()
  4. System

    • system_identity()
    • system_user_groups()
    • system_users()
  5. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 anandaerditya/routeros-api-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 361
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-07