- What does alexpechkarev/google-geocoder do in Laravel?
- It is a thin Laravel wrapper around the Google Maps Geocoding API v3. It lets you convert addresses into latitude and longitude coordinates and reverse geocode coordinates back into addresses through a service provider, facade, and config file. It was built for the Laravel 5.x era and imposes little architectural opinion.
- How do I install alexpechkarev/google-geocoder?
- Install it with Composer using composer require alexpechkarev/google-geocoder, then publish the package config and add your Google API key. This works cleanly only on the legacy stack the package targets. On Laravel 8+ or PHP 8+, Composer resolution will likely fail because of old illuminate/support and Guzzle constraints.
- Which Laravel and PHP versions does this Google Geocoder package support?
- It fits Laravel 5.1 through 5.5 on PHP 5.6 through 7.1. There is no PHP 8 support statement and no Laravel package auto-discovery. Treat it as legacy-only rather than a candidate for Laravel 10 or 11.
- Why does composer require fail on Laravel 10 or PHP 8?
- The last release was 2017-09-27, so its illuminate/support constraint is in the 5.x range and its Guzzle constraint collides with the Guzzle 7 that ships with Laravel 8+. Forcing installation with platform overrides can lead to runtime fatal errors on untyped or deprecated signatures. A fork or replacement is usually safer.
- How do I configure the Google API key for this package?
- The package publishes a config file that holds the API key. You must also have a Google Cloud project with the Geocoding API enabled, a billing account, and HTTPS requests, since Google now makes keys and billing mandatory. Keep the key in environment variables and restrict it in Google Cloud.
- Does it support both forward and reverse geocoding?
- Yes, the wrapper covers both directions: address-to-coordinates and coordinates-to-address. If you need batch lookups, component filtering, or multi-provider failover, verify support in the README or plan a replacement. The package is a thin client, not a full geocoding platform.
- How does the package handle Google geocoding error responses?
- Its error handling predates Google's expanded error surface such as OVER_DAILY_LIMIT and REQUEST_DENIED, and it likely surfaces raw Google payloads. There are no typed exceptions or modern PSR-18 and PSR-17 abstractions. Wrap calls in your own adapter and translate failures into application-specific exceptions.
- Can I cache Google geocoding results in Laravel?
- Be careful: Google's terms restrict how geocoding results may be cached and stored, and permanent storage is generally limited to latitude and longitude rather than full result payloads. Addresses are also PII in many jurisdictions. Any caching layer you add around this package needs legal review before production use.
- How should I test code that uses the GoogleGeocoder facade?
- Static facade calls couple your code to the package namespace and response objects, which makes testing awkward. Put an internal Geocoder contract in front of it, with address in and normalized result out, and fake that contract in your tests. If you must use the facade directly, mock it and assert only the normalized output you need.
- Is alexpechkarev/google-geocoder still maintained, and what should I use instead?
- It has had no release in roughly eight years, has 74 stars, and appears in SCA and audit tooling as an unmaintained dependency, so you own all future CVEs. For modern Laravel, use geocoder-php/Geocoder with the Google Maps provider or write a small client over Laravel's Http facade. A single HTTPS GET with an API key is not much complexity, and replacing the package removes the abandonment risk.