Package Data | |
---|---|
Maintainer Username: | Fuhrmann |
Maintainer Contact: | fuhrmanns@gmail.com (Ricardo Fuhrmann) |
Package Create Date: | 2013-09-01 |
Package Last Update: | 2021-02-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-19 03:18:08 |
Package Statistics | |
---|---|
Total Downloads: | 1,548 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 10 |
Total Watchers: | 3 |
Total Forks: | 5 |
Total Open Issues: | 1 |
A Laravel package that uses geoPlugin web service to fetch information from an IP. It will store in cache the IP information and it will expire in 1 week.
Install this package through Composer. To your composer.json file, add:
"fuhrmann/larageo-plugin": "dev-master"
Next, run the Composer update comand
$ composer update
Add the service provider to app/config/app.php, within the providers array.
'providers' => array(
// ...
'Fuhrmann\LarageoPlugin\ServiceProvider',
),
In the same file config/app.php
add the alias:
'aliases' => array(
//...
'LarageoPlugin' => 'Fuhrmann\LarageoPlugin\Facade',
),
You can specify an IP:
$info = LarageoPlugin::getInfo('177.34.13.248'); // get info from a IP
var_dump($info);
Or use it without any param:
$info = LarageoPlugin::getInfo(); // get info from the IP of the user acessing the page
var_dump($info);
This is the output:
object(stdClass)[155]
public 'geoplugin_request' => string '177.34.13.248' (length=13)
public 'geoplugin_status' => int 200
public 'geoplugin_credit' => string 'Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\'http://www.maxmind.com\'>http://www.maxmind.com</a>.' (length=145)
public 'geoplugin_city' => string 'Campo Grande' (length=12)
public 'geoplugin_region' => string 'Mato Grosso do Sul' (length=18)
public 'geoplugin_areaCode' => string '0' (length=1)
public 'geoplugin_dmaCode' => string '0' (length=1)
public 'geoplugin_countryCode' => string 'BR' (length=2)
public 'geoplugin_countryName' => string 'Brazil' (length=6)
public 'geoplugin_continentCode' => string 'SA' (length=2)
public 'geoplugin_latitude' => string '-20.450001' (length=10)
public 'geoplugin_longitude' => string '-54.616699' (length=10)
public 'geoplugin_regionCode' => string '11' (length=2)
public 'geoplugin_regionName' => string 'Mato Grosso do Sul' (length=18)
public 'geoplugin_currencyCode' => string 'BRL' (length=3)
public 'geoplugin_currencySymbol' => string 'R$' (length=10)
public 'geoplugin_currencySymbol_UTF8' => string 'R$' (length=2)
public 'geoplugin_currencyConverter' => float 2.383
Another useful example: You can also just return one field, e.g. city from in one call:
$userCity = LarageoPlugin::getInfo()->geoplugin_city; // get the city from the user IP
var_dump($userCity);
Output:
string 'Campo Grande' (length=12)
If you want more info about the geoPlugin web service, click here.