承接 middlewares/geolocation 相关项目开发

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

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

middlewares/geolocation

最新稳定版本:v3.2.0

Composer 安装命令:

composer require middlewares/geolocation

包简介

Middleware to geolocate the client using the ip address

README 文档

README

Latest Version on Packagist Software License Testing Total Downloads ![SensioLabs Insight][ico-sensiolabs]

Middleware to geolocate the client using the ip address and Geocoder and save the result as a request attribute.

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/geolocation.

composer require middlewares/geolocation

Example

$freeGeoIpProvider = new Geocoder\Provider\FreeGeoIp($adapter);

$dispatcher = new Dispatcher([
    new Middlewares\Geolocation($freeGeoIpProvider),

    function ($request) {
        //Get the client location
        $location = $request->getAttribute('client-location');

        $country = $location->first()->getCountry();
    }
]);

$response = $dispatcher->dispatch(new ServerRequest());

Options

__construct(Geocoder\Provider\Provider $provider)

The geocoder provider used to geolocate the client.

It's also recommended to configure it to caching responses.

ipAttribute(string $ipAttribute)

By default uses the REMOTE_ADDR server parameter to get the client ip. This option allows to use a request attribute. Useful to combine with a ip detection middleware, for example client-ip.

attribute(string $attribute)

The attribute name used to store the client addresses in the server request. By default is client-location.

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

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

统计信息

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

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固