Tiger_Location
@api
Tiger_Location — the Location Service facade.
One entry point for every location lookup. Throw it a partial address (suggest/geocode), a lat/lng (reverse), or an IP (ip); it routes to the configured, capable adapter and returns the same Tiger_Location_Place payload regardless of provider. Providers are chosen by config, per operation group:
tiger.location.address.provider = "nominatim" ; suggest / geocode / reverse
tiger.location.ip.provider = "ipapi" ; ip
tiger.location.adapters.
Graceful by design: an unset provider, a missing/incapable adapter, or a provider error yields empty results (never a fatal), so a form's autocomplete just quietly does nothing when unconfigured. Register more adapters with Tiger_Location::register().
Methods
register()
register(string $name, string $class): void
Register (or replace) a provider name -> adapter class.
$namestring— the provider name (case-insensitive)$classstring— the adapter class to instantiate for it
suggest()
suggest(string $query, array $opts = []): array
Suggest address matches for a partial query via the configured address provider.
$querystring— the partial address text$optsarray— provider options (e.g. country bias)
Returns array — the suggestions, or [] when unconfigured or on error
geocode()
geocode(string $query, array $opts = []): array
Geocode a query to structured place(s) via the configured address provider.
$querystring— the address text to geocode$optsarray— provider options (e.g. country bias)
Returns array — the matches, or [] when unconfigured or on error
reverse()
reverse(float $lat, float $lng, array $opts = []): ?Tiger_Location_Place
Reverse-geocode a coordinate to the nearest place via the configured address provider.
$latfloat— the latitude$lngfloat— the longitude$optsarray— provider options
Returns ?Tiger_Location_Place — the place, or null when unconfigured or on error
ip()
ip(string $ip, array $opts = []): ?Tiger_Location_Place
Geolocate an IP address via the configured IP provider.
$ipstring— the IP address to look up$optsarray— provider options
Returns ?Tiger_Location_Place — the place, or null on an invalid IP, unconfigured, or error