承接 ocolin/easymt 相关项目开发

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

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

ocolin/easymt

Composer 安装命令:

composer require ocolin/easymt

包简介

Simple wrapper for evil freelancers RouterOS API client

README 文档

README

This library provides a simple and basic interface to useing evilfreelancer's RouterOS API as well as SNMP calls for Mikrotik devices.

This library is going away and being replaced by ocolin/routeros

Requirements

PHP 8.3+

Adding a composer module:

In your composer.json

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/ocolin/EasySNMP"
        }
    ],

Then run

composer require ocolin/eastmt

API

Most of the funcionality comes from:

https://github.com/EvilFreelancer/routeros-api-php

This wrapper simply allows you to use environment variables in advance.

Settings

Arguments

Any host related arguments such as IP will take precedent the config file or environment variables

Environment Variables

Environment variables will override any settings from the default config file. A prefix is required so that multiple entries can be stored. The prefix will be appended to the beginning of the environment variable used. Here are the defaults:

With prefix 'EXAMPLE1':

$_ENV['EXAMPLE1_MT_IP'];
$_ENV['EXAMPLE1_MT_USER'];
$_ENV['EXAMPLE1_MT_PASS'];

Default config file

You can also edit src/config.json if you don't want to use arguments or environment variables. This will however only allow for a single device to be used.

Examples

Example 1: Using settings in config.json

use Ocolin\EasyMT\API;

$output = API::query( '/ip/arp/print' )->read();

Example 2: Using parameters:

use Ocolin\EasyMT\API;

$output = API::query(
        endpoint: '/ip/arp/print',
        where: [
            ['address', '127.0.0.1'],
            ['address', '127.0.0.2']
        ],
        operations: '|'
)->read();

Example 3: Using environment variables

use Ocolin\EasyMT\API;

$_ENV['EXAMPLE_MT_IP']   = '127.0.0.1';
$_ENV['EXAMPLE_MT_USER'] = 'admin';
$_ENV['EXAMPLE_MT_PASS'] = 'pass';

$output = API::query(
    endpoint: '/ip/arp/print',
      prefix: 'EXAMPLE'
)->read();

Example 4: Using argument ip and local environment variables

use Ocolin\EasyMT\API;

$output = API::query(
    endpoint: '/ip/arp/print',
      prefix: 'EXAMPLE',
       local: true
)->read();

SNMP

Calls

Function Description
port_Alias( int ) Get name of alias for a port
ports() Get list of port information
ethernet() Get list of ethernet interface data
port_Name( int ) Get name of a port
system() Get system information
iPs() List of IP address information
routes() List of IP routes
media() List of Media information
forward() List of forwarding entries
ARP() List ARP table
uptime() Uptime infromation
storage() List of storage information
processor() Processor information
organization() List of orgnaization information
dot1dTpFdbEntry() List of bridge forwarding information
power() List of power related information
health() Device health information
license() License information
os() Information about OS
neighbors() List of neighbor information
ifStats() List of interface statistic information
partitions() List of partition information
optical() List of optical interface information
leaseCount() Get number of DHCP leases

Example

Example 1: Using environment variable

use Ocolin\EasyMT\SNMP;

$_ENV['EXAMPLE1_SNMP_COMMUNITY'] = public;
$_ENV['EXAMPLE1_SNMP_VERSION'] = 2;
$_ENV['EXAMPLE1_MT_IP'] = '127.0.0.1';

$snmp = new \Ocolin\EasyMT\SNMP(
    prefix: 'EXAMPLE1'
);

$output = $snmp->health();

Example 2: Using argument variables

use Ocolin\EasyMT\SNMP;

$snmp = new \Ocolin\EasyMT\SNMP(
           ip: '127.0.0.1',
    community: 'public',
      version: 2
);

$output = $snmp->health();

Example 3: Using default SNMP settings

use Ocolin\EasyMT\SNMP;

$snmp = new \Ocolin\EasyMT\SNMP(
    ip: '127.0.0.1'
);
$output = $snmp->health();

Example Output:

stdClass Object
(
    [temperature] => stdClass Object
        (
            [Value] => 27
            [Unit] => 1
            [UnitName] => celsius
        )

    [cpu-temperature] => stdClass Object
        (
            [Value] => 48
            [Unit] => 1
            [UnitName] => celsius
        )

    [fan1-speed] => stdClass Object
        (
            [Value] => 4200
            [Unit] => 2
            [UnitName] => rpm
        )

    [fan2-speed] => stdClass Object
        (
            [Value] => 3990
            [Unit] => 2
            [UnitName] => rpm
        )

    [psu1-state] => stdClass Object
        (
            [Value] => 0
            [Unit] => 6
            [UnitName] => status
        )

    [psu2-state] => stdClass Object
        (
            [Value] => 1
            [Unit] => 6
            [UnitName] => status
        )
)

ocolin/easymt 适用场景与选型建议

ocolin/easymt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ocolin/easymt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ocolin/easymt 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-25