How to get location information from ip address in Laravel ?
In this post we will give you information about How to get location information from ip address in Laravel ?. Hear we will give you detail about How to get location information from ip address in Laravel ?And how to use it also give you demo for it if it is necessary.
Sometimes, we may require to get user information from ip address in Laravel 5 application at that time this article can help to get info from IP.
We can get information from IP Address using “stevebauman/location” composer package for Laravel. “stevebauman/location” through we can get info like country Name, country Code, region Code, region Name, city Name, zip Code, iso Code, postal Code, latitude, longitude, metro Code, metro Code. They will provide bellow following details that they can get from IP.
Solve - fatal: Unable to create '/myproject/.git/index.lock': File exi
In this post we will give you information about Solve - fatal: Unable to create '/myproject/.git/index.lock': File exi. Hear we will give you detail about Solve - fatal: Unable to create '/myproject/.git/index.lock': File exiAnd how to use it also give you demo for it if it is necessary.
When i was working on my laravel 5 application, i did all the changes i did but when i had gone for push then i found this fatal error. It's not able to create index.lock file in .git folder. I also give full permission to .git folder and also try to remove direct index.lock file from .git directory but same error like as bellow.
Error
fatal: Unable to create '/var/www/me/theme_backend/.git/index.lock': File exists.
But at last i found how can i resolve this problem, just run bellow command and it will work.
rm -f ./.git/index.lock
Hope this code and post will helped you for implement Solve - fatal: Unable to create '/myproject/.git/index.lock': File exi. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
So first we require to install “stevebauman/location” composer package by using following command.
composer require stevebauman/location
After successfully install package, open
config/app.php file and add service provider and alias.
config/app.php
'providers' => [
....
StevebaumanLocationLocationServiceProvider::class,
],
'aliases' => [
....
'Location' => 'StevebaumanLocationFacadesLocation',
]
we have to also make public configuration file by following command, after run this command you will find config/location.php file. So run bellow command:
php artisan vendor:publish
Now we are ready to get Location details from user Ip, so you can write code on your route file like as bellow:
Example:
Route::get('get-ip-details', function () {
$ip = '66.102.0.0';
$data = Location::get($ip);
dd($data);
});
You will find output like as bellow:
Output
StevebaumanLocationPosition Object
(
[countryName] =>
[countryCode] => US
[regionCode] =>
[regionName] => California
[cityName] => Mountain View
[zipCode] => 94043
[isoCode] =>
[postalCode] =>
[latitude] => 37.4192
[longitude] => -122.0574
[metroCode] =>
[areaCode] =>
[driver] => StevebaumanLocationDriversIpInfo
)
I hope it can help you…
Video
Hope this code and post will helped you for implement How to get location information from ip address in Laravel ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs