承接 webmaster/maxmind-db-reader 相关项目开发

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

邮箱: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.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

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