Skip to content

Commit 095121c

Browse files
authored
chore: rename package (#63)
* chore: rename package * Fix styling * more renaming * rename classes * rename * rename * fix names * delete old * rename * rename more * rename * Fix styling * fix composer * fix config * update namespace * update * fix more * fix facade
1 parent a1b3994 commit 095121c

32 files changed

+343
-346
lines changed

README.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
GeoIP
1+
IPGeolocation
22
=============
33

4-
> Geoip Wrapper with Laravel Support
4+
> IP Geolocation Wrapper with Laravel Support
55
6-
[![Latest Stable Version](https://poser.pugx.org/pulkitjalan/geoip/v/stable?format=flat-square)](https://packagist.org/packages/pulkitjalan/geoip)
6+
[![Latest Stable Version](https://poser.pugx.org/pulkitjalan/ip-geolocation/v/stable?format=flat-square)](https://packagist.org/packages/pulkitjalan/ip-geolocation)
77
[![MIT License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://www.opensource.org/licenses/MIT)
8-
[![Run Tests](https://github.com/pulkitjalan/geoip/actions/workflows/run-tests.yml/badge.svg)](https://github.com/pulkitjalan/geoip/actions/workflows/run-tests.yml)
9-
[![Coverage](https://codecov.io/gh/pulkitjalan/geoip/branch/main/graph/badge.svg?token=JTB1ASXAB0)](https://codecov.io/gh/pulkitjalan/geoip)
10-
[![Total Downloads](https://img.shields.io/packagist/dt/pulkitjalan/geoip.svg?style=flat-square)](https://packagist.org/packages/pulkitjalan/geoip)
8+
[![Run Tests](https://github.com/pulkitjalan/ip-geolocation/actions/workflows/run-tests.yml/badge.svg)](https://github.com/pulkitjalan/ip-geolocation/actions/workflows/run-tests.yml)
9+
[![Coverage](https://codecov.io/gh/pulkitjalan/ip-geolocation/branch/main/graph/badge.svg?token=JTB1ASXAB0)](https://codecov.io/gh/pulkitjalan/ip-geolocation)
10+
[![Total Downloads](https://img.shields.io/packagist/dt/pulkitjalan/ip-geolocation.svg?style=flat-square)](https://packagist.org/packages/pulkitjalan/ip-geolocation)
1111

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

@@ -23,7 +23,7 @@ GeoIP
2323
Install via composer
2424

2525
```bash
26-
composer require pulkitjalan/geoip
26+
composer require pulkitjalan/ip-geolocation
2727
```
2828

2929
### Laravel
@@ -33,36 +33,36 @@ There is a Laravel service provider and facade available.
3333
Add the following to the `providers` array in your `config/app.php`
3434

3535
```php
36-
PulkitJalan\GeoIP\GeoIPServiceProvider::class
36+
PulkitJalan\IPGeolocation\IPGeolocationServiceProvider::class
3737
```
3838

3939
Next add the following to the `aliases` array in your `config/app.php`
4040

4141
```php
42-
'GeoIP' => PulkitJalan\GeoIP\Facades\GeoIP::class
42+
'IPGeolocation' => PulkitJalan\IPGeolocation\Facades\IPGeolocation::class
4343
```
4444

45-
Next run `php artisan vendor:publish --provider="PulkitJalan\GeoIP\GeoIPServiceProvider" --tag="config"` to publish the config file.
45+
Next run `php artisan vendor:publish --provider="PulkitJalan\IPGeolocation\IPGeolocationServiceProvider" --tag="config"` to publish the config file.
4646

4747
#### Using an older version of PHP / Laravel?
4848

4949
If you are on a PHP version below 8.1 or a Laravel version below 9.0, use an older version of this package.
5050

5151
## Usage
5252

53-
The geoip class takes a config array as the first parameter or defaults to using the `ip-api` driver.
53+
The ipGeolocation class takes a config array as the first parameter or defaults to using the `ip-api` driver.
5454

5555
Example:
5656

5757
```php
5858
<?php
5959

60-
use PulkitJalan\GeoIP\GeoIP
60+
use PulkitJalan\IPGeolocation\IPGeolocation
6161

62-
$geoip = new GeoIP();
62+
$ip = new IPGeolocation();
6363

64-
$lat = $geoip->getLatitude(); // 51.5141
65-
$lon = $geoip->getLongitude(); // -3.1969
64+
$lat = $ip->getLatitude(); // 51.5141
65+
$lon = $ip->getLongitude(); // -3.1969
6666
```
6767

6868
#### IP-API
@@ -126,137 +126,137 @@ $config = [
126126

127127
### Laravel
128128

129-
To use this package in Laravel, simply update the config file in `config/geoip.php` to get the same effect. The driver can be set using the `GEOIP_DRIVER` env.
129+
To use this package in Laravel, simply update the config file in `config/ip-geolocation.php` to get the same effect. The driver can be set using the `IPGEOLOCATION_DRIVER` env.
130130

131131
### Available Methods
132132

133-
GeoIP will try to determin the ip using the following http headers: `HTTP_CLIENT_IP`, `HTTP_X_FORWARDED_FOR`, `HTTP_X_FORWARDED`, `HTTP_FORWARDED_FOR`, `HTTP_FORWARDED`, `REMOTE_ADDR` in this order. Optionally use the `setIp` method to set it.
133+
IPGeolocation will try to determin the ip using the following http headers: `HTTP_CLIENT_IP`, `HTTP_X_FORWARDED_FOR`, `HTTP_X_FORWARDED`, `HTTP_FORWARDED_FOR`, `HTTP_FORWARDED`, `REMOTE_ADDR` in this order. Optionally use the `setIp` method to set it.
134134

135135
```php
136-
$geoip->setIp('127.0.0.1');
136+
$ip->setIp('127.0.0.1');
137137

138138
// Laravel
139-
GeoIP::setIp('127.0.0.1');
139+
IPGeolocation::setIp('127.0.0.1');
140140
```
141141

142142
There are a number of available methods to pull out the required information. All methods will return an empty string if data is unavailable.
143143

144144
Get latitude
145145

146146
```php
147-
$geoip->getLatitude();
147+
$ip->getLatitude();
148148

149149
// Laravel
150-
GeoIP::getLatitude();
150+
IPGeolocation::getLatitude();
151151
```
152152

153153
Get longitude
154154

155155
```php
156-
$geoip->getLongitude();
156+
$ip->getLongitude();
157157

158158
// Laravel
159-
GeoIP::getLongitude();
159+
IPGeolocation::getLongitude();
160160
```
161161

162162
Get city
163163

164164
```php
165-
$geoip->getCity();
165+
$ip->getCity();
166166

167167
// Laravel
168-
GeoIP::getCity();
168+
IPGeolocation::getCity();
169169
```
170170

171171
Get country
172172

173173
```php
174-
$geoip->getCountry();
174+
$ip->getCountry();
175175

176176
// Laravel
177-
GeoIP::getCountry();
177+
IPGeolocation::getCountry();
178178
```
179179

180180
Get country code
181181

182182
```php
183-
$geoip->getCountryCode();
183+
$ip->getCountryCode();
184184

185185
// Laravel
186-
GeoIP::getCountryCode();
186+
IPGeolocation::getCountryCode();
187187
```
188188

189189
Get region
190190

191191
```php
192-
$geoip->getRegion();
192+
$ip->getRegion();
193193

194194
// Laravel
195-
GeoIP::getRegion();
195+
IPGeolocation::getRegion();
196196
```
197197

198198
Get region code
199199

200200
```php
201-
$geoip->getRegionCode();
201+
$ip->getRegionCode();
202202

203203
// Laravel
204-
GeoIP::getRegionCode();
204+
IPGeolocation::getRegionCode();
205205
```
206206

207207
Get postal code
208208

209209
```php
210-
$geoip->getPostalCode();
210+
$ip->getPostalCode();
211211

212212
// Laravel
213-
GeoIP::getPostalCode();
213+
IPGeolocation::getPostalCode();
214214
```
215215

216216
Get timezone
217217

218218
```php
219-
$geoip->getTimezone();
219+
$ip->getTimezone();
220220

221221
// Laravel
222-
GeoIP::getTimezone();
222+
IPGeolocation::getTimezone();
223223
```
224224

225225
Get isp (not supported on all drivers)
226226

227227
```php
228-
$geoip->getIsp();
228+
$ip->getIsp();
229229

230230
// Laravel
231-
GeoIP::getIsp();
231+
IPGeolocation::getIsp();
232232
```
233233

234234
Get all geo information
235235

236236
```php
237-
$geoip->get(); // returns array
237+
$ip->get(); // returns array
238238

239239
// Laravel
240-
GeoIP::get(); // returns array
240+
IPGeolocation::get(); // returns array
241241
```
242242

243243
Get raw geo information
244244

245245
```php
246-
$geoip->getRaw(); // different drivers will return different data types
246+
$ip->getRaw(); // different drivers will return different data types
247247

248248
// Laravel
249-
GeoIP::getRaw(); // different drivers will return different data types
249+
IPGeolocation::getRaw(); // different drivers will return different data types
250250
```
251251

252252
### Update Database
253253

254-
There is an update command available to help with updating and installing a local geoip database. The following will download and install/update the database file to `/path/to/database.mmdb`. [As of 30th December 2019, Maxmind requires users to create an account and use a license key to download the databases](https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/).
254+
There is an update command available to help with updating and installing a local ip geolocation database. The following will download and install/update the database file to `/path/to/database.mmdb`. [As of 30th December 2019, Maxmind requires users to create an account and use a license key to download the databases](https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/).
255255

256256
```php
257257
<?php
258258

259-
use PulkitJalan\GeoIP\GeoIPUpdater
259+
use PulkitJalan\IPGeolocation\IPGeolocationUpdater
260260

261261
$config = [
262262
'driver' => 'maxmind_database',
@@ -266,12 +266,12 @@ $config = [
266266
],
267267
];
268268

269-
(new GeoIPUpdater($config))->update();
269+
(new IPGeolocationUpdater($config))->update();
270270
```
271271

272272
### Laravel
273273

274-
Once you have registered the service provider (supports auto discovery), you can use the command `php artisan geoip:update`
274+
Once you have registered the service provider (supports auto discovery), you can use the command `php artisan ip-geolocation:update`
275275

276276
## Services
277277

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2-
"name": "pulkitjalan/geoip",
3-
"description": "Geoip Wrapper with Laravel Support",
4-
"homepage": "https://github.com/pulkitjalan/geoip",
2+
"name": "pulkitjalan/ip-geolocation",
3+
"description": "IP Geolocation Wrapper with Laravel Support",
4+
"homepage": "https://github.com/pulkitjalan/ip-geolocation",
55
"keywords": [
6-
"geoip",
6+
"ip-geolocation",
7+
"geolocation",
78
"ip-api",
89
"maxmind",
910
"ipstack"
@@ -27,24 +28,24 @@
2728
},
2829
"autoload": {
2930
"psr-4": {
30-
"PulkitJalan\\GeoIP\\": "src"
31+
"PulkitJalan\\IPGeolocation\\": "src"
3132
},
3233
"files": [
3334
"helpers.php"
3435
]
3536
},
3637
"autoload-dev": {
3738
"psr-4": {
38-
"PulkitJalan\\GeoIP\\Tests\\": "tests"
39+
"PulkitJalan\\IPGeolocation\\Tests\\": "tests"
3940
}
4041
},
4142
"extra": {
4243
"laravel": {
4344
"providers": [
44-
"PulkitJalan\\GeoIP\\GeoIPServiceProvider"
45+
"PulkitJalan\\IPGeolocation\\IPGeolocationServiceProvider"
4546
],
4647
"aliases": {
47-
"GeoIP": "PulkitJalan\\GeoIP\\Facades\\GeoIP"
48+
"IPGeolocation": "PulkitJalan\\IPGeolocation\\Facades\\IPGeolocation"
4849
}
4950
}
5051
},

config/geoip.php renamed to config/ip-geolocation.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
return [
44
/*
55
|--------------------------------------------------------------------------
6-
| GeoIP Driver Type
6+
| IPGeolocation Driver Type
77
|--------------------------------------------------------------------------
88
|
99
| Supported: "ip-api", "maxmind_database", "maxmind_api", "ipstack"
1010
|
1111
*/
12-
'driver' => env('GEOIP_DRIVER', 'ip-api'),
12+
'driver' => env('IPGEOLOCATION_DRIVER', 'ip-api'),
1313

1414
/*
1515
|--------------------------------------------------------------------------
1616
| Return random ipaddresses (useful for dev envs)
1717
|--------------------------------------------------------------------------
1818
*/
19-
'random' => env('GEOIP_RANDOM', false),
19+
'random' => env('IPGEOLOCATION_RANDOM', false),
2020

2121
/*
2222
|--------------------------------------------------------------------------
@@ -25,8 +25,8 @@
2525
*/
2626
'ip-api' => [
2727
// Check out pro here: https://signup.ip-api.com/
28-
'key' => env('GEOIP_IPAPI_KEY'),
29-
'lang' => env('GEOIP_IPAPI_LANG'),
28+
'key' => env('IPGEOLOCATION_IPAPI_KEY'),
29+
'lang' => env('IPGEOLOCATION_IPAPI_LANG'),
3030
],
3131

3232
/*
@@ -36,10 +36,10 @@
3636
*/
3737
'maxmind_database' => [
3838
// Example: app_path().'/database/maxmind/GeoLite2-City.mmdb'
39-
'database' => base_path().'/'.env('GEOIP_MAXMIND_DATABASE', 'database/geoip/GeoLite2-City.mmdb'),
39+
'database' => base_path().'/'.env('IPGEOLOCATION_MAXMIND_DATABASE', 'database/ipGeolocation/GeoLite2-City.mmdb'),
4040

4141
// The license key is required for database updates
42-
'license_key' => env('GEOIP_MAXMIND_LICENSE_KEY'),
42+
'license_key' => env('IPGEOLOCATION_MAXMIND_LICENSE_KEY'),
4343
],
4444

4545
/*
@@ -48,10 +48,10 @@
4848
|--------------------------------------------------------------------------
4949
*/
5050
'maxmind_api' => [
51-
'user_id' => env('GEOIP_MAXMIND_USER_ID'),
52-
'license_key' => env('GEOIP_MAXMIND_LICENSE_KEY'),
51+
'user_id' => env('IPGEOLOCATION_MAXMIND_USER_ID'),
52+
'license_key' => env('IPGEOLOCATION_MAXMIND_LICENSE_KEY'),
5353
//maxmind api will default to paid service. Use 'geolite.info' for free GeoLite2 Web service. https://github.com/maxmind/GeoIP2-php#usage-1
54-
'host' => env('GEOIP_MAXMIND_HOST'),
54+
'host' => env('IPGEOLOCATION_MAXMIND_HOST'),
5555
//local required on client call but defaults to 'en' for english.
5656
'locales' => ['en'],
5757
],
@@ -63,6 +63,6 @@
6363
*/
6464
'ipstack' => [
6565
// Get your access key here: https://ipstack.com/product
66-
'key' => env('GEOIP_IPSTACK_KEY'),
66+
'key' => env('IPGEOLOCATION_IPSTACK_KEY'),
6767
],
6868
];

helpers.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<?php
22

3-
if (! function_exists('geoip')) {
3+
use PulkitJalan\IPGeolocation\IPGeolocation;
4+
5+
if (! function_exists('ipGeolocation')) {
46
/**
5-
* Get an instance of the current geoip.
7+
* Get an instance of the current ip geolocation.
68
*
7-
* @return \PulkitJalan\GeoIP\GeoIP
9+
* @return \PulkitJalan\IPGeolocation\IPGeolocation
810
*/
9-
function geoip($key = null)
11+
function ipGeolocation($key = null)
1012
{
1113
if (is_null($key)) {
12-
return app('geoip');
14+
return app(IPGeolocation::class);
1315
}
1416

15-
return app('geoip')->{'get'.ucwords(camel_case($key))}();
17+
return app(IPGeolocation::class)->{'get'.ucwords(camel_case($key))}();
1618
}
1719
}

0 commit comments

Comments
 (0)