dev-master
9999999-devYii2 location extension, retrieve a user's location from their IP address using an external web services
MIT
The Requires
by Ahmed SAIDI
extension yii2 ip location
Yii2 location extension, retrieve a user's location from their IP address using an external web services
Retrieve a user's location from their IP address using an external web services, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require ap369/yii2-location dev-master
or add, (*4)
"ap369/yii2-location": "dev-master"
to the require section of your composer.json
file., (*5)
Once the extension is installed, use it in your code like this:, (*6)
$position = Location::get('44.85.3.2'); echo $position->latitude; echo $position->longitude;
If you don't provide an IP address, it will default to Yii::$app->request->userIP
., (*7)
Additionally, you can chose what driver will be used to resolve the IP address location, by passing its class as the second parameter., (*8)
$position = Location::get('44.85.3.2', FreeGeoIp::class);
You can also pass null
as the address to have it automatically resolved:, (*9)
$position = Location::get(null,GeoPlugin::class); // position from GeoPluin
Currently, the following drivers are supported by this extension:, (*10)
This extension is based on stevebauman/location laravel extension., (*11)
Yii2 location extension, retrieve a user's location from their IP address using an external web services
MIT
extension yii2 ip location