You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-11Lines changed: 21 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Currently, there are the following adapters:
17
17
*`CurlHttpAdapter` to use [cURL](http://php.net/manual/book.curl.php);
18
18
*`GuzzleHttpAdapter` to use [Guzzle](https://github.com/guzzle/guzzle), PHP 5.3+ HTTP client and framework for building RESTful web service clients;
19
19
*`SocketHttpAdapter` to use a [socket](http://www.php.net/manual/function.fsockopen.php);
20
-
*`ZendHttpAdapter` to use [Zend Http Client](http://framework.zend.com/manual/2.0/en/modules/zend.http.client.html).
20
+
*`ZendHttpAdapter` to use [Zend Http Client](http://framework.zend.com/manual/2.0/en/modules/zend.http.client.html);
21
21
*`GeoIP2Adapter` to use [GeoIP2 Database Reader](https://github.com/maxmind/GeoIP2-php#database-reader) or the [Webservice Client](https://github.com/maxmind/GeoIP2-php#web-service-client) by MaxMind.
22
22
23
23
@@ -265,23 +265,33 @@ be used in production. For more information, please read [issue #301](https://gi
265
265
266
266
### GeoIP2DatabaseProvider ###
267
267
268
-
The `GeoIP2Provider` named `maxmind_geoip2` is able to geocode **IPv4 and IPv6 addresses**
269
-
only - it makes use of the MaxMind GeoIP2 databases or the webservice.
268
+
The `GeoIP2Provider` named `maxmind_geoip2` is able to geocode **IPv4 and IPv6
269
+
addresses** only - it makes use of the MaxMind GeoIP2 databases or the
270
+
webservice.
270
271
271
-
It requires either the [database file](http://dev.maxmind.com/geoip/geoip2/geolite2/), or the [webservice](http://dev.maxmind.com/geoip/geoip2/web-services/) - represented by the GeoIP2 Provider, which is injected to the `GeoIP2Adapter`. The [geoip2/geoip2](https://packagist.org/packages/geoip2/geoip2) package must be installed.
272
+
It requires either the [database
273
+
file](http://dev.maxmind.com/geoip/geoip2/geolite2/), or the
274
+
[webservice](http://dev.maxmind.com/geoip/geoip2/web-services/) - represented by
275
+
the GeoIP2 Provider, which is injected to the `GeoIP2Adapter`. The
276
+
[geoip2/geoip2](https://packagist.org/packages/geoip2/geoip2) package must be
277
+
installed.
272
278
273
279
This provider will only work with the corresponding `GeoIP2Adapter`.
274
280
275
-
**Usage:**
281
+
##### Usage
276
282
277
-
// Maxmind GeoIP2 Provider: e.g. the database reader
278
-
$reader = new \GeoIp2\Database\Reader('/path/to/database');
283
+
```php
284
+
<?php
279
285
280
-
$adapter = new \Geocoder\HttpAdapter\GeoIP2Adapter($reader);
281
-
$provider = new \Geocoder\Provider\GeoIP2Provider($adapter);
282
-
$geocoder = new \Geocoder\Geocoder($provider);
286
+
// Maxmind GeoIP2 Provider: e.g. the database reader
287
+
$reader = new \GeoIp2\Database\Reader('/path/to/database');
283
288
284
-
$result = $geocoder->geocode('74.200.247.59');
289
+
$adapter = new \Geocoder\HttpAdapter\GeoIP2Adapter($reader);
290
+
$provider = new \Geocoder\Provider\GeoIP2Provider($adapter);
0 commit comments