1001pharmacies/geolocation-bundle
symfony/bundle compatibility layers (e.g., illuminate/container wrappers). However, Laravel’s ecosystem (e.g., service providers, facades) may require minor adaptations.config or environment variables, enabling runtime flexibility (e.g., fallback chains).guzzlehttp/guzzle <v7).Container changes, HttpClient deprecations)?spatie/laravel-geotools)?geocoder-php/geocoder) with active development?bind()/singleton() methods. Use AppServiceProvider to register the bundle with Laravel’s container:
$this->app->register(\Meup\GeoLocationBundle\MeupGeoLocationBundle::class);
config/geolocation.php for provider-specific settings (e.g., API keys, endpoints).HttpClient for modern request handling.spatie/laravel-db-document) for storing geocoded data.config system.laravel/framework v9.52+ for container compatibility.ContainerAware traits if conflicts arise with Laravel’s Container changes.env() or Vault for secrets.Meup\GeoLocationBundle\Provider\ProviderInterface and register via bundle’s services.yml.composer require 1001pharmacies/geolocation-bundle.php artisan vendor:publish --provider="Meup\GeoLocationBundle\MeupGeoLocationBundle".config/geolocation.php:
'providers' => [
'primary' => 'google',
'fallback' => ['nominatim', 'mapquest'],
],
'google' => [
'key' => env('GOOGLE_MAPS_API_KEY'),
'endpoint' => 'https://maps.googleapis.com/maps/api/geocode/json',
],
Locator service into controllers/services:
use Meup\GeoLocationBundle\Locator\LocatorInterface;
public function __construct(private LocatorInterface $locator) {}
public function findCoordinates(string $address) {
$coordinates = $this->locator->locate($address);
return response()->json($coordinates);
}
LocatorInterface in unit tests to avoid external API calls.guzzlehttp/guzzle and symfony/dependency-injection for security patches. Pin versions in composer.json to avoid auto-updates.config/geolocation.php.Log facade or a dedicated service.dd() or dump() on provider responses; enable Guzzle debugging:
$client = new \GuzzleHttp\Client(['debug' => fopen('guzzle.log', 'w')]);
OVER_QUERY_LIMIT).latitude, longitude) for spatial queries using Laravel Scout or PostgreSQL’s GIS extensions.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Primary provider outage | No geocoding for critical features | Configure fallback chain in config/geolocation.php. |
| API key revocation | All geocoding fails | Automate key rotation; use Laravel’s env() with encrypted |
How can I help you explore Laravel packages today?