Skip to content

Commit 9e93570

Browse files
committed
Add update_url to config, fix tests
1 parent 4d98b03 commit 9e93570

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/vendor
2-
*.mmdb
32
composer.phar
43
composer.lock
54
.DS_Store

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ $ php artisan vendor:publish
5151

5252
A configuration file will be publish to `config/geoip.php`
5353

54-
Update max mind cities database
54+
Update max mind cities database:
5555

5656
~~~
5757
$ php artisan geoip:update
5858
~~~
5959

60+
**Database Service**: To use the database version of [MaxMind](http://www.maxmind.com) services download the `GeoLite2-City.mmdb` from [http://dev.maxmind.com/geoip/geoip2/geolite2/](http://dev.maxmind.com/geoip/geoip2/geolite2/) and extract it to `storage/app/geoip.mmdb`. And that's it.
61+
6062
## Usage
6163

6264
Get the location data for a website visitor:
@@ -95,12 +97,6 @@ array (
9597

9698
In the case that a location is not found the fallback location will be returned with the `default` parameter set to `true`. To set your own default change it in the configurations `config/geoip.php`
9799

98-
## Services
99-
100-
### [MaxMind](http://www.maxmind.com)
101-
102-
- **Database Service**: To use the database version of MaxMind services download the `GeoLite2-City.mmdb` from [http://dev.maxmind.com/geoip/geoip2/geolite2/](http://dev.maxmind.com/geoip/geoip2/geolite2/) and extract it to `database/maxmind/`. And that's it.
103-
104100
## Change Log
105101

106102
#### v0.2.0

src/Torann/GeoIP/GeoIPUpdater.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public function update()
4444
*/
4545
protected function updateMaxMindDatabase()
4646
{
47-
$maxMindDatabaseUrl = 'http://geolite.maxmind.com/download/geoip/database/';
47+
$maxMindDatabaseUrl = $this->config->get('geoip.maxmind.update_url');
4848
$databasePath = $this->config->get('geoip.maxmind.database_path');
4949

50-
$client = new Client(['base_uri' => $maxMindDatabaseUrl]);
51-
$response = $client->get('GeoLite2-City.mmdb.gz');
50+
$client = new Client();
51+
$response = $client->get($maxMindDatabaseUrl);
5252
$file = $response->getBody();
5353

5454
@file_put_contents($databasePath, gzdecode($file));

src/config/geoip.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'user_id' => env('GEOIP_USER_ID'),
2828
'license_key' => env('GEOIP_LICENSE_KEY'),
2929
'database_path' => storage_path('app/geoip.mmdb'),
30+
'update_url' => 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz',
3031
),
3132

3233
/*

tests/GeoIPUpdaterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function test_max_mind_updater()
2525
'maxmind' => [
2626
'type' => 'database',
2727
'database_path' => $database,
28+
'update_url' => 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz',
2829
],
2930
],
3031
]);

tests/data/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)