Providers
Each HTTP provider talks to its API through Laravel’s own HTTP client — no vendor SDKs — with the shared timeout, its own retry settings and its own rate-limit budget. Add the credentials you have to .env:
# IPinfo — the token is optional; the anonymous tier works without one
IPINFO_TOKEN=your-ipinfo-token
# IP2Location.io
IP2LOCATION_API_KEY=your-ip2location-key
# Google Geocoding + Distance Matrix
GOOGLE_MAPS_API_KEY=your-google-maps-key
# Static location returned by the "default" provider
GEOLOCATION_DEFAULT_HUMAN_READABLE="Springfield, US"
GEOLOCATION_DEFAULT_STREET="Main Street 1"
GEOLOCATION_DEFAULT_CITY=Springfield
GEOLOCATION_DEFAULT_COUNTRY_ISO_CODE=US
GEOLOCATION_DEFAULT_LATITUDE=39.7817
GEOLOCATION_DEFAULT_LONGITUDE=-89.6501What each provider returns
| Provider | Credentials | Fills | type |
|---|---|---|---|
ipinfo | Optional token (IPINFO_TOKEN) | city, region, countryIsoCode, postalCode, timezone, latitude/longitude | Ip |
ip2location | API key (IP2LOCATION_API_KEY) | city, region, countryIsoCode, postalCode, timezone, latitude/longitude | Ip |
maxmind_* | See MaxMind | city, region (first subdivision), countryIsoCode, postalCode, timezone, latitude/longitude — English names | Ip |
google | API key (GOOGLE_MAPS_API_KEY) | humanReadable (formatted address), street, city, region, postalCode, countryIsoCode, latitude/longitude — no timezone | Geolocation |
default | None | The configured default.* values; region, postalCode and timezone stay empty. Answers null while nothing is configured | Default |
IPinfo
Looks up /{ip}/json on ipinfo.io. The token is optional: the anonymous tier works without one, and the bearer header is only sent when a token is set. Invalid IPs and non-IP queries return null without a request.
IP2Location.io
Calls the ip2location.io API with your key and the IP; without IP2LOCATION_API_KEY the request goes out unauthenticated. A response carrying an error, a non-2xx status or an invalid IP resolves to null, and so does the all-empty reply it gives for a private or reserved IP.
The only bundled provider that handles coordinates and addresses: reverse geocoding for coordinate queries, forward geocoding for address queries, both via the Geocoding API. It is also the only bundled DistanceProvider (Distance Matrix API, driving or walking). IP queries return null, so Google sits happily behind the IP providers.
Default
Returns the static location from default.* with type Default — but only once you configure it; while every default.* value is empty or zero (as shipped), it answers null. Set it when your app should always have something to work with — for example your head office or the country you mostly serve. The fallback is never cached.
The two MaxMind providers have their own section — see MaxMind.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.