spatie/geocoder
Convert any address into GPS coordinates in Laravel/PHP using Google’s Geocoding API. Simple facade-based calls return lat/lng plus accuracy, formatted address, and viewport data. Ideal for mapping, location search, and address validation.
spatie/geocoder package is a perfect fit for applications requiring address-to-coordinate conversion (e.g., location-based services, logistics, real estate, or mapping tools). It abstracts geocoding logic, reducing dependency on raw API integrations.Geocoder::setCache()). Supports batch geocoding and reverse geocoding (coordinates → address)..env or service provider bindings, reducing hardcoding.Geocoded, GeocodeFailed) for observability and custom logic (e.g., logging, retries).accuracy field)?Geocoder::fake() or custom adapters?)Geocodable trait for automatic geocoding on model attributes (e.g., address → lat/lng).app()->bind(Geocoder::class, fn() => Geocoder::create(...))).GeocodeJob) for async processing.POST /api/geocode) with rate limiting.lat/lng fields are floating-point (e.g., decimal(10,8)).composer require spatie/geocoder.php artisan vendor:publish --provider="Spatie\Geocoder\GeocoderServiceProvider"..env with API keys (e.g., GOOGLE_MAPS_API_KEY).Address):
use Spatie\Geocoder\Geocodable;
class Address extends Model implements Geocodable { ... }
Address::geocode()).Geocoder::setRetryOnFailure(true)).Geocoder::setCache(new RedisCache)).spatie/geocoder and provider adapters regularly (e.g., spatie/google-maps-geocoder).AddressFactory::new()->geocode()).Geocoder::setLogPath(storage_path('logs/geocoder.log'));
throttle) for public geocoding endpoints.How can I help you explore Laravel packages today?