承接 brainstud/geolocation 相关项目开发

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

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

brainstud/geolocation

Composer 安装命令:

composer require brainstud/geolocation

包简介

A laravel package to get the country and timezone (geolocation) of the request

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Get the country & timezone of the request with the cloudflare country header or fallback to a paid geo-locator API.

$location = Geolocation::getLocation($request);
// { countryCode: "NL", timeZone: "Europe/Amsterdam" }

The aim of this package prioritize the cloudflare header to keep costs down. Only if that fails an API-call will be done. By this philosophy only minimal info will be available. (country code and timezone)

Installation

You can install the package via composer:

composer require brainstud/geolocation

You can publish the config file with:

php artisan vendor:publish --tag="geolocation-config"

This is the contents of the published config file:

return [
    'header' => 'CF-IPCountry', // The cloudflare header that contains the country code
    'geocoder' => GeoLocator::IpRegistry, // The geocoder to use if the header is empty
    'ip-registry' => [ // Credentials for the ip registry API
        'base_url' => env('IP_REGISTRY_URL', 'https://api.ipregistry.co'),
        'key' => env('IP_REGISTRY_KEY'),
    ],
    'ip-stack' => [ // Credentials for the ip stack API
        'base_url' => env('IP_STACK_URL', 'https://api.ipstack.com'),
        'key' => env('IP_STACK_KEY'),
    ],
    'cache_ttl' => DateInterval::createFromDateString('2 months'), // Cache TTL for the geocoder services.
];

Supported services

Contributing

You can add a geocoder by creating a class in the src/GeoLocators folder that implements GeoLocatorContract. Then add it to the GeoLocator enum and GeoLocatorFactory.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固