Skip to content

Commit 2e87bff

Browse files
committed
Merge pull request #30 from dotpack/dev
Dev
2 parents fd874da + e6a71e3 commit 2e87bff

File tree

11 files changed

+328
-164
lines changed

11 files changed

+328
-164
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: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ $ php artisan vendor:publish
5151

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

54+
Update max mind cities database:
55+
56+
~~~
57+
$ php artisan geoip:update
58+
~~~
59+
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.
5461

5562
## Usage
5663

@@ -90,12 +97,6 @@ array (
9097

9198
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`
9299

93-
## Services
94-
95-
### [MaxMind](http://www.maxmind.com)
96-
97-
- **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.
98-
99100
## Change Log
100101

101102
#### v0.2.0

composer.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "torann/geoip",
33
"description": "Supports the two main GeoIP services (infoDB and Maxmind).",
44
"keywords": ["laravel", "laravel 5", "geoip", "location", "geolocation"],
5-
"license": "BSD 2-Clause",
5+
"license": "BSD 2-Clause",
66
"authors": [
77
{
88
"name": "Daniel Stainback",
@@ -12,16 +12,25 @@
1212
"require": {
1313
"php": ">=5.3.0",
1414
"illuminate/support": "~5.0",
15-
"geoip2/geoip2": "2.1.1"
15+
"illuminate/session": "~5.0",
16+
"illuminate/console": "~5.0",
17+
"illuminate/config": "~5.0",
18+
"monolog/monolog": "~1.11",
19+
"geoip2/geoip2": "~2.1",
20+
"guzzlehttp/guzzle": "^6.0"
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "~4.0",
24+
"phpspec/phpspec": "~2.1"
1625
},
1726
"autoload": {
1827
"psr-4": {
19-
"Torann\\GeoIP\\": "src/Torann/GeoIP"
28+
"Torann\\GeoIP\\": "src/Torann/GeoIP"
2029
}
2130
},
2231
"extra": {
2332
"branch-alias": {
2433
"dev-master": "0.2-dev"
2534
}
2635
}
27-
}
36+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php namespace Torann\GeoIP\Console;
2+
3+
use Illuminate\Config\Repository;
4+
use Illuminate\Console\Command;
5+
use Torann\GeoIP\GeoIPUpdater;
6+
7+
class UpdateCommand extends Command
8+
{
9+
/**
10+
* The console command name.
11+
*
12+
* @var string
13+
*/
14+
protected $name = 'geoip:update';
15+
16+
/**
17+
* The console command description.
18+
*
19+
* @var string
20+
*/
21+
protected $description = 'Update geoip database files to the latest version';
22+
23+
/**
24+
* @var \Torann\GeoIP\GeoIPUpdater
25+
*/
26+
protected $geoIPUpdater;
27+
28+
/**
29+
* Create a new console command instance.
30+
*
31+
* @param \Illuminate\Config\Repository $config
32+
*/
33+
public function __construct(Repository $config)
34+
{
35+
parent::__construct();
36+
37+
$this->geoIPUpdater = new GeoIPUpdater($config);
38+
}
39+
40+
/**
41+
* Execute the console command.
42+
*
43+
* @return void
44+
*/
45+
public function fire()
46+
{
47+
$result = $this->geoIPUpdater->update();
48+
49+
if (!$result) {
50+
$this->error('Update failed!');
51+
52+
return;
53+
}
54+
55+
$this->info('New update file ('.$result.') installed.');
56+
}
57+
}

0 commit comments

Comments
 (0)