Download the PHP package stevebauman/location without Composer
On this page you can find all versions of the php package stevebauman/location. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
All versions of location with dependencies
Informations about the package location
Retrieve a user's location from their IP address using external web services, or through a flat-file database hosted on your server.
- PHP >= 7.0
- Laravel >= 5.0
- cURL extension enabled
Install location using
Add the service provider in
Important: If you're using Laravel 5.5 or above, you can skip the registration of the service provider, as it is registered automatically.
Publish the configuration file (this will create a
location.php file inside the
Retrieve a client's location
Note: This method retrieves the user's IP address via
Retrieve the location of a specific IP address
Available drivers at the moment are:
Setting up MaxMind with a self-hosted database (optional)
We encourage setting up MaxMind as a fallback driver using a local database, as it allows you to bypass any throttling that could occur from using external web services.
To set up MaxMind to retrieve the user's location from your own server, you must:
- Create a maxmind account.
- Sign in.
- Click "Download Files" from the left-hand navigation menu.
- Download the
- Extract the downloaded file (you may need to use an application such as 7zip if on Windows).
- Create a
maxmindfolder inside your Laravel application's
- Place the
GeoLite2-City.mmdbfile into the
maxminddirectory. You should end up with a folder path of:
- Set your default location
Stevebauman\Location\Drivers\MaxMind::class, and you're all set!
Note: Keep in mind, you'll need to update this file on a regular basis to retrieve the most current information from clients.
In the config file, you can specify as many fallback drivers as you wish. It is
recommended to install the MaxMind database
.mmdb file, so you are always
retrieving some generic location information for the user.
If an exception occurs trying to grab a driver (such as a 404 error if the providers API changes), it will automatically use the next driver in line.
Creating your own drivers
To create your own driver, simply create a class in your application, and extend the abstract Driver:
Then, insert your driver class name into the configuration file:
Location is versioned under the Semantic Versioning guidelines as much as possible.
Releases will be numbered with the following format:
And constructed with the following guidelines:
- Breaking backward compatibility bumps the major and resets the minor and patch.
- New additions without breaking backward compatibility bumps the minor and resets the patch.
- Bug fixes and misc changes bumps the patch.
Minor versions are not maintained individually, and you're encouraged to upgrade through to the next minor version.
Major versions are maintained individually through separate branches.