darsyn/ip 问题修复 & 功能扩展

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

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

darsyn/ip

Composer 安装命令:

composer require darsyn/ip

包简介

An immutable IP Address value object that provides several different notations, including helper functions.

README 文档

README

IP is an immutable value object for (both version 4 and 6) IP addresses. Several helper methods are provided for ranges, broadcast and network addresses, subnet masks, whether an IP is a certain type (defined by RFC's), etc.

This project aims for simplicity of use and any contribution towards that goal - whether a bug report, modifications to the codebase, or an improvement to the accuracy or readability of the documentation - are always welcome.

Documentation

Full documentation is available in the docs/ folder.

Compatibility

This library has extensive test coverage using PHPUnit on all supported PHP versions.

Versions 5.x.x of this library are compatible with PHP versions 5.6 to 8.3 (and will continue to receive bug fixes).

Versions 6.x.x of this library are compatible with PHP versions 7.1 and above (currently confirmed up to 8.5), and will receive continued support for future versions of PHP (also accepting proposed new features).

Static analysis is performed with PHPStan at max level on PHP 7.4 and 8.5, using core, bleeding edge, and deprecation rules.

The Doctrine features for this library have been split off into their own package, darsyn/ip-doctrine.

Brief Example

  • There are three main classes: IPv4, IPv6, and Multi (for both version 4 and 6 addresses).
  • Objects are created using a static factory method IpInterface::factory() instead of the constructor to speed up internal processes.
  • When using Multi, the default strategy for representing version 4 addresses internally is IPv4-mapped.
<?php declare(strict_types=1);

use Darsyn\IP\Exception;
use Darsyn\IP\Version\IPv4;

try {
    $ip = IPv4::factory('192.168.0.1');
} catch (Exception\InvalidIpAddressException $e) {
    exit('The IP address supplied is invalid!');
}

$companyNetwork = IPv4::factory('216.58.198.174');
if (!$ip->inRange($companyNetwork, 25)) {
    throw new \Exception('Request not from a known company IP address.');
}

// Is it coming from the local network?
if (!$ip->isPrivateUse()) {
    record_visit($ip->getBinary(), $_SERVER['HTTP_USER_AGENT']);
}

Code of Conduct

This project includes and adheres to the Contributor Covenant as a Code of Conduct.

License

Please see the separate license file included in this repository for a full copy of the MIT license, which this project is licensed under.

Authors

If you make a contribution (submit a pull request), don't forget to add your name here!

darsyn/ip 适用场景与选型建议

darsyn/ip 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.06M 次下载、GitHub Stars 达 257, 最近一次更新时间为 2015 年 08 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.06M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 258
  • 点击次数: 24
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 257
  • Watchers: 8
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-22