kseven/ip-tools
Composer 安装命令:
composer require kseven/ip-tools
包简介
PHP IP Tools for manipulation with IPv4 and IPv6
README 文档
README
Universal IP Tools for manipulation on IPv4 and IPv6.
Require this package with Composer
Install this package through Composer.
Edit your project's composer.json file to require
kseven/ip-tools.
Create composer.json file:
{ "name": "yourproject/yourproject", "type": "project", "require": { "kseven/ip-tools": "~1.1.0" } }
And run composer update
Or run a command in your command line:
composer require kseven/ip-tools
Usage
<?php $loader = require __DIR__.'/vendor/autoload.php'; use KSeven\IPTools\Ip; // Validating $status = Ip::isValid('192.168.1.1'); // true $status = Ip::isValid('192.168.1.256'); // false // ip2long, long2ip /// IPv4 $long = Ip::ip2long('192.168.1.1'); // 3232235777 $dec = Ip::long2ip('3232235777'); // 192.168.1.1 /// IPv6 $long = Ip::ip2long('fe80:0:0:0:202:b3ff:fe1e:8329'); // 338288524927261089654163772891438416681 $dec = Ip::long2ip('338288524927261089654163772891438416681', true); // fe80::202:b3ff:fe1e:8329 // Matching /// IPv4 $status = Ip::match('192.168.1.1', '192.168.1.*'); // true $status = Ip::match('192.168.1.1', '192.168.*.*'); // true $status = Ip::match('192.168.1.1', '192.168.*.*'); // true $status = Ip::match('192.168.1.1', '192.168.0.*'); // false $status = Ip::match('192.168.1.1', '192.168.1/24'); // true $status = Ip::match('192.168.1.1', '192.168.1.1/255.255.255.0'); // true $status = Ip::match('192.168.1.1', '192.168.0/24'); // false $status = Ip::match('192.168.1.1', '192.168.0.0/255.255.255.0'); // false $status = Ip::match('192.168.1.5', '192.168.1.1-192.168.1.10'); // true $status = Ip::match('192.168.5.5', '192.168.1.1-192.168.10.10'); // true $status = Ip::match('192.168.5.5', '192.168.6.1-192.168.6.10'); $status = Ip::match('192.168.1.1', array('122.128.123.123', '192.168.1.*', '192.168.123.124')); // true $status = Ip::match('192.168.1.1', array('192.168.123.*', '192.168.123.124')); /// IPv6 $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // true $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // true $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:9652', '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:9999'); // true $status = Ip::match('2001:cdba:0000:0000:0000:0000:3258:9652', '2001:cdba:0000:0000:0000:0000:3257:*'); // false $status = Ip::match('2001:cdba:0000:0000:0000:1234:3258:9652', '2001:cdba:0000:0000:0000:0000:*:*'); // false $status = Ip::match('2001:cdba:0000:0000:0000:0000:3257:7778', '2001:cdba:0000:0000:0000:0000:3257:1234-2001:cdba:0000:0000:0000:0000:3257:7777'); // false
This code is available on Github. Pull requests are welcome.
Troubleshooting
If you like living on the edge, please report any bugs you find on the PHP IP Tools issues page.
Contributing
See CONTRIBUTING.md for information.
License
Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.
Credits
Full credit list in CREDITS
kseven/ip-tools 适用场景与选型建议
kseven/ip-tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ipv6」 「tools」 「utilities」 「IP」 「ipv4」 「compare」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kseven/ip-tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kseven/ip-tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kseven/ip-tools 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A set of useful PHP classes.
A Laravel package to retrieve data from Google Search Console
A stand-alone class implementation of the IPv4+IPv6 IP+CIDR aggregator from CIDRAM.
A collection of enhancements and utilities for the Silverstripe UserForms module
PHP Library for manipulating network addresses (IPv4 and IPv6)
Manages IPv4 and IPv6 addresses and subnets
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-29