sikofitt/generate-mac 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sikofitt/generate-mac

Composer 安装命令:

composer require sikofitt/generate-mac

包简介

Generates dummy mac addresses

README 文档

README

Small library to generate unique private mac addresses

Install

Requires PHP >=8.2, For versions compatible with PHP 7.x use the 0.x branch.

composer

composer require sikofitt/generate-mac

Usage

use Sikofitt\GenerateMac\Mac;

$mac = new Mac(); // default separator is ':'
// or
$mac->setSeparator(Mac::SEPARATOR_COLON);
$address = $mac->getAddress(); // ab:cd:ef:01:23:45

$mac = new Mac(Mac::SEPARATOR_DASH);
// or
$mac->setSeparator(Mac::SEPARATOR_DASH);
$address = $mac->getAddress(); // ab-cd-ef-01-23-45

$mac = new Mac(Mac::SEPARATOR_NONE);
// or
$mac->setSeparator(Mac::SEPARATOR_NONE);
$address = $mac->getAddress(); // abcdef012345

If you don't care that it is unique you can remove the check for private mac prefixes.

$mac = new Mac(Mac::SEPARATOR_COLON, false);
// or
$mac->setUnique(false);

$address = $mac->getAddress();

// '52:54:00:ab:cd:ef',  QEMU virtual NIC prefix 52:54:00
// It's really not likely there will be a collision though.

Generate multiple mac addresses

$addresses = $mac->getAddresses(10);

var_dump($addresses);
/*
 *   array (
 *       0 => '8a:20:0b:b7:c4:62',
 *       1 => '56:7d:47:56:e8:bd',
 *       2 => '2a:ae:7b:44:6f:9d',
 *       3 => '6a:36:1a:7c:04:3a',
 *       4 => '3a:3d:93:f5:a6:12',
 *       5 => '8a:85:ce:11:2c:a2',
 *       6 => '06:54:6f:b1:11:48',
 *       7 => 'c6:fe:9d:86:38:dd',
 *       8 => 'ba:39:b3:a2:a1:fa',
 *       9 => '32:73:c0:b3:62:27',
 *   );
 */

// if you call this with 1 as the count it will still
// return an array [0 => '32:73:c0:b3:62:27']

Using the console component

The console script requires symfony/console

user@localhost:~/generate-mac$ bin/generate-mac --count (int) --output (json|plain|string) --separator (none|colon|dash)
  • --count Generate {count} mac addresses
  • --output Output in selected format
    • string: (default) Outputs the mac address(es) with formatting
    • plain: Outputs the mac address(es) with no formatting
    • json: Output the mac address(es) in json format
  • --separator Outputs with the selected operator
    • colon: ':' (default)
    • dash: '-'
    • none: ''

See bin/generate-mac --help

Test

user@localhost:~/generate-mac$ vendor/bin/phpunit

License

GPL-3.0

sikofitt/generate-mac 适用场景与选型建议

sikofitt/generate-mac 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「random」 「generate」 「MAC」 「Mac Address」 「media access control」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 sikofitt/generate-mac 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2018-11-30