Skip to content

Commit 3f01cfa

Browse files
committed
updated readme
1 parent e795e02 commit 3f01cfa

File tree

5 files changed

+28
-64
lines changed

5 files changed

+28
-64
lines changed

README.md

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ GeoIP
1212

1313
## Supported Drivers ([Services](#services))
1414

15-
* [FreeGeoIP](https://freegeoip.net/)
15+
* [IPStack](https://ipstack.com/)
1616
* [IP-API](http://ip-api.com/)
1717
* [Maxmind](https://www.maxmind.com/)
1818
* [Telize](https://market.mashape.com/fcambus/telize/)
@@ -23,16 +23,12 @@ GeoIP
2323

2424
## Installation
2525

26-
Install via composer - edit your `composer.json` to require the package.
26+
Install via composer
2727

28-
```js
29-
"require": {
30-
"pulkitjalan/geoip": "2.*"
31-
}
28+
```bash
29+
composer require pulkitjalan/geoip
3230
```
3331

34-
Then run `composer update` in your terminal to pull it in.
35-
3632
### Laravel
3733

3834
There is a Laravel service provider and facade available.
@@ -72,27 +68,16 @@ $lat = $geoip->getLatitude(); // 51.5141
7268
$lon = $geoip->getLongitude(); // -3.1969
7369
```
7470

75-
#### FreeGeoIP
71+
#### IPStack
7672

77-
To use the freegeoip as the driver set the config.
73+
To use the ipstack as the driver set the config.
7874

7975
Example:
8076
```php
8177
$config = [
82-
'driver' => 'freegeoip',
83-
'freegeoip' => [
84-
'secure' => true,
85-
],
86-
];
87-
```
88-
89-
Custom install example:
90-
```php
91-
$config = [
92-
'driver' => 'freegeoip',
93-
'freegeoip' => [
94-
'url' => 'freegeoip.example.com', // or with a port (freegeoip.example.com:8080)
95-
'secure' => true, // or false
78+
'driver' => 'ipstack',
79+
'ipstack' => [
80+
'key' => 'YOUR IPSTACK KEY',
9681
],
9782
];
9883
```
@@ -107,9 +92,6 @@ $config = [
10792
'driver' => 'ip-api',
10893
'ip-api' => [
10994
'key' => 'YOUR IP-API KEY',
110-
111-
// optionally set secure (https) connection (default: false)
112-
'secure' => true
11395
],
11496
];
11597
```
@@ -148,7 +130,7 @@ Example:
148130
$config = [
149131
'driver' => 'telize',
150132
'telize' => [
151-
'key' => 'YOUR IP-API KEY',
133+
'key' => 'YOUR TELIZE KEY',
152134
],
153135
];
154136
```
@@ -300,13 +282,13 @@ $geoipUpdater->update();
300282

301283
### Laravel
302284

303-
Once you have registered the service provider, you can use the command `php artisan geoip:update`
285+
Once you have registered the service provider (supports auto discovery), you can use the command `php artisan geoip:update`
304286

305287
## Services
306288

307-
#### FreeGeoIP
289+
#### IPStack
308290

309-
Freegeoip is a free service that can also be used instead of the database file or the paid maxmind service. They do have some limitations so please have a look at the [website](https://freegeoip.net/) first. You can also run a [custom install](https://github.com/fiorix/freegeoip) and use that instead.
291+
IPStack offers a JSON IP and GeoIP REST API allowing to get a visitor IP address and to query location information from any IP address.
310292

311293
#### IP-API
312294

src/Drivers/IPApiDriver.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,14 @@ public function getRaw($ip)
5454
*/
5555
protected function getUrl($ip)
5656
{
57-
$protocol = 'http:';
58-
if (array_get($this->config, 'secure', false)) {
59-
$protocol = 'https:';
60-
}
61-
6257
// default to free service
6358
// free service does not support https
6459
$baseUrl = 'http://ip-api.com/json/';
6560
$key = '';
6661

6762
// if key is set change to pro service
6863
if (array_get($this->config, 'key', false)) {
69-
$baseUrl = $protocol.'//pro.ip-api.com/json/';
64+
$baseUrl = 'https://pro.ip-api.com/json/';
7065
$key = array_get($this->config, 'key');
7166
}
7267

src/config/config.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@
5050
|
5151
*/
5252
'key' => env('GEOIP_IPAPI_KEY'),
53-
54-
/*
55-
|--------------------------------------------------------------------------
56-
| IP-API Secure connection
57-
|--------------------------------------------------------------------------
58-
|
59-
| Use http or https
60-
| Only applicable with the Pro service
61-
|
62-
*/
63-
'secure' => env('GEOIP_IPAPI_SECURE', true),
6453
],
6554

6655
/*

tests/GeoIPTest.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function test_maxmind_exception()
4848
public function test_maxmind_database_exception()
4949
{
5050
$config = [
51-
'driver' => 'maxmind',
51+
'driver' => 'maxmind',
5252
'maxmind' => [
5353
'database' => __DIR__.'/data/GeoIP2-City.mmdb',
5454
],
@@ -62,7 +62,7 @@ public function test_maxmind_database_exception()
6262
public function test_maxmind_invalid_database_exception()
6363
{
6464
$config = [
65-
'driver' => 'maxmind',
65+
'driver' => 'maxmind',
6666
'maxmind' => [
6767
'database' => __FILE__,
6868
],
@@ -76,7 +76,7 @@ public function test_maxmind_invalid_database_exception()
7676
public function test_maxmind_web_api_exception()
7777
{
7878
$config = [
79-
'driver' => 'maxmind',
79+
'driver' => 'maxmind',
8080
'maxmind' => [
8181
'user_id' => 'test',
8282
],
@@ -90,9 +90,9 @@ public function test_maxmind_web_api_exception()
9090
public function test_maxmind_web_api_authentication_exception()
9191
{
9292
$config = [
93-
'driver' => 'maxmind',
93+
'driver' => 'maxmind',
9494
'maxmind' => [
95-
'user_id' => 'test',
95+
'user_id' => 'test',
9696
'license_key' => 'test',
9797
],
9898
];
@@ -108,9 +108,9 @@ public function test_maxmind_web_api_authentication_exception()
108108
public function test_maxmind_web_api_authentication_exception_getRaw()
109109
{
110110
$config = [
111-
'driver' => 'maxmind',
111+
'driver' => 'maxmind',
112112
'maxmind' => [
113-
'user_id' => 'test',
113+
'user_id' => 'test',
114114
'license_key' => 'test',
115115
],
116116
];
@@ -182,7 +182,7 @@ public function test_ipstack_exception_without_key()
182182
public function test_maxmind_database()
183183
{
184184
$config = [
185-
'driver' => 'maxmind',
185+
'driver' => 'maxmind',
186186
'maxmind' => [
187187
'database' => __DIR__.'/data/GeoIP2-City-Test.mmdb',
188188
],
@@ -217,8 +217,7 @@ public function test_ip_api_pro_exception()
217217
$config = [
218218
'driver' => 'ip-api',
219219
'ip-api' => [
220-
'key' => 'test',
221-
'secure' => true,
220+
'key' => 'test',
222221
],
223222
];
224223

@@ -235,8 +234,7 @@ public function test_ip_api_pro_exception_getRaw()
235234
$config = [
236235
'driver' => 'ip-api',
237236
'ip-api' => [
238-
'key' => 'test',
239-
'secure' => true,
237+
'key' => 'test',
240238
],
241239
];
242240

tests/GeoIPUpdaterTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function test_maxmind_updater()
2424
{
2525
$database = __DIR__.'/data/GeoLite2-City.mmdb';
2626
$config = [
27-
'driver' => 'maxmind',
27+
'driver' => 'maxmind',
2828
'maxmind' => [
2929
'database' => $database,
3030
],
@@ -41,10 +41,10 @@ public function test_maxmind_updater_invalid_url()
4141
{
4242
$database = __DIR__.'/data/GeoLite2-City.mmdb';
4343
$config = [
44-
'driver' => 'maxmind',
44+
'driver' => 'maxmind',
4545
'maxmind' => [
4646
'database' => $database,
47-
'download' => 'http://example.com/maxmind_database.mmdb.gz'
47+
'download' => 'http://example.com/maxmind_database.mmdb.gz',
4848
],
4949
];
5050

@@ -57,7 +57,7 @@ public function test_maxmind_updater_dir_not_exist()
5757
{
5858
$database = __DIR__.'/data/new_dir/GeoLite2-City.mmdb';
5959
$config = [
60-
'driver' => 'maxmind',
60+
'driver' => 'maxmind',
6161
'maxmind' => [
6262
'database' => $database,
6363
],

0 commit comments

Comments
 (0)