⚠️ Before using MaxMind driver, you must install the geoip2/geoip2 package using the Composer package manager.
The database location to use is specified in the config file in the “services” section under maxmind_database.
php artisan geoip:update downloads the database. It authenticates against MaxMind’s download permalink with HTTP Basic auth, so set both credentials from your MaxMind account:
MAXMIND_ACCOUNT_ID=123456
MAXMIND_LICENSE_KEY=your-license-key
Use edition_id (default GeoLite2-City) to pick the edition; the downloaded database must be of that type. If account_id is empty, the legacy URL with the license key in the query string is used instead. A non-empty update_url is used as is and no credentials are added to it; it must contain the literal suffix=tar.gz, and the same URL with suffix=tar.gz.sha256 must serve the checksum. database_path may be a symlink: the link is kept and its target is replaced. The update always verifies the archive’s SHA-256 checksum and the database edition, and swaps the file atomically; on any failure the existing database is kept and the license key is never included in error output.
Note: geoip:update must be run before lookups work. Until then the package does not fall back to any bundled database; lookups return the default location and the failure is logged.
If geoip:update failed in an earlier version of this package, the error output may have contained your license key (as part of the download URL). Rotate the license key in your MaxMind account.
'service' => 'maxmind_database',
The free ip-api.com tier is HTTP-only: lookups are unencrypted and can be spoofed by anyone on the network path, so it is not suitable for production. Set key to use the HTTPS Pro endpoint; with a key, requests always use HTTPS and secure is ignored. With 'secure' => true and no key a warning is logged at most once a day when the default cache store is shared and persistent (e.g. redis, file, database); with the array or null store, or without a cache, it is logged each time the service boots; set 'secure' => false to acknowledge plain HTTP and silence it.
All HTTP-based services and maxmind_api use the top-level connect_timeout (2 s) and timeout (5 s) values from config/geoip.php. Put connect_timeout or timeout inside a service’s section to override them for that service.