webmaster/maxmind-db-reader 问题修复 & 功能扩展

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

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

webmaster/maxmind-db-reader

最新稳定版本:v1.0.0

Composer 安装命令:

composer require webmaster/maxmind-db-reader

包简介

This is the MaxMind DB Reader for Hyperf or other resident process framework. It preloads the entire mmdb file into memory, with the memory usage equal to the size of the mmdb file. It has no disk IO operations and maintains query efficiency at the microsecond level.

README 文档

README

Description

This is the MaxMind DB Reader for PHP Hyperf or other resident process framework. It preloads the entire mmdb file into memory, with the memory usage equal to the size of the mmdb file. It has no disk IO operations and maintains query efficiency at the microsecond level.

Install Dependencies

Run in your project root:

php composer.phar require webmaster/maxmind-db-reader:~1.0

Usage

Example

<?php
namespace App\Service;

use MaxMind\Db\Reader;

class IpLocationService
{
    private $reader;

    public function maxMind(): Reader
    {
        $dbFile = storage_path() . '/ip/GeoIP2-City.mmdb';
        $dbContents = file_get_contents($dbFile, false);
        return new Reader($dbFile, $dbContents);
    }

    public function search(string $ip): string
    {
        if (! $this->reader) {
            $this->reader = $this->maxMind();
        }

        $location = $this->reader->get($ip);

        return $location;
    }

}

Support

Please report all issues with this code using the GitHub issue tracker.

Copyright and License

This software is Copyright (c) 2014-2025 by MaxMind, Inc.

Modified and developed by the Admin.IM community.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-08-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固