Repository navigation
Installation
Nick Hamnett edited this page Sep 29, 2026
·
1 revision
- PHP 8.4 or newer
- Laravel 11, 12 or 13 (
illuminate/contracts ^11.0 || ^12.0 || ^13.0) - Composer
The MaxMind database reader is pure PHP, but MaxMind recommends one of the following extensions:
-
ext-bcmathorext-gmp, required for decoding larger integers with the pure PHP decoder -
ext-maxminddb, a C-based decoder that provides significantly faster lookups
composer require sameoldnick/laravel-geolocatorThe service provider is auto-discovered. Publish the configuration file:
php artisan vendor:publish --tag=geolocator-configDownload the MaxMind databases:
php artisan geolocator:update-iplocationdbThe package does not ship the databases. The command downloads the country, city and ASN editions (both IPv4 and IPv6) into storage/app/geolocation. Lookups throw an InvalidArgumentException when the configured database file is missing, so run the command once after installing, or point the package at databases you already have.
See Configuration for every path and environment variable, and Database updates for what the command does on later runs.
- Network: the update command downloads over HTTPS from a public CDN, so whatever machine runs it needs outbound access (or a proxy) at install and update time. Lookups themselves are offline.
-
Filesystem: the databases are written to
storage/app/geolocation, which needs to be writable and large enough for the editions you enable (the city edition is the largest). On a read-only or ephemeral filesystem, either bake the databases into your image or point theIPLOCATIONDB_*_PATHvariables at a writable mount. -
Long-running workers: each edition's reader is cached by the scoped reader provider that built it, so
queue:workdiscards it before every job and Octane discards it between requests — both read a replaced database without a restart. Only a process that keeps one open across an update (a long-running console command, or the job that is mid-flight) serves the old file until it finishes.