sivolobov/geocoder-ipgeobase
Composer 安装命令:
composer require sivolobov/geocoder-ipgeobase
包简介
Geocoder provider for IpGeoBase service (Russia).
README 文档
README
This repository hosts IpGeoBase provider to use with Geocoder library.
Installation
The recommended way to install this package is through Composer:
composer require sivolobov/geocoder-ipgeobase
Usage
You need to read Geocoder's usage documentaion first.
Simple example:
$curl = new \Ivory\HttpAdapter\CurlHttpAdapter();
$geocoder = new \Geocoder\Provider\IpGeoBase($curl);
$addressCollection = $geocoder->geocode('213.180.193.3');
Symfony integration
To use IpGeoBase in Symfony project you need to install BazingaGeocoderBundle:
After configuring bundle you need to define custom provider. So add these lines to your services.yml:
bazinga_geocoder.provider.ip_geo_base:
class: Geocoder\Provider\IpGeoBase
arguments:
- "@bazinga_geocoder.geocoder.adapter"
tags:
- {name: "bazinga_geocoder.provider"}
public: false
lazy: true
Now you can use it as:
$addressCollection = $this->get('geocoder')->using('ip_geo_base')->geocode($request->getClientIp());
Notes
Note that geocode() return AddressCollection instance but IpGeoBase always return only one address for one IP.
So that collection will always have only one element.
License
Geocoder IpGeoBase provider is released under the MIT License. See the bundled LICENSE file for details.
统计信息
- 总下载量: 75
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-12