- How do I integrate Bing Maps geocoding into a Laravel app?
- Install the package via Composer (`composer require geocoder-php/bing-maps-provider`), add your API key to `.env`, and configure the provider in `config/services.php` under the `geocoder` array. Use `Geocoder::geocodeQuery()` or `Geocoder::geocode()` for forward/reverse lookups.
- What Laravel versions does this package support?
- The package works with Laravel 10.x+ and requires PHP 8.1+. Ensure you’re using `geocoder-php/geocoder` v4.x+ for compatibility. Check the package’s `composer.json` for exact constraints.
- Is there a free tier for Bing Maps API, and what are the limits?
- Yes, Bing Maps offers a free tier with 50,000 transactions/month. Monitor usage closely, as exceeding limits may incur costs. Consider caching or async queues to optimize calls.
- Can I use this package without the main `geocoder-php/geocoder` library?
- No, this provider depends on the `geocoder-php/geocoder` library (~1.5k stars). Install it first (`composer require geocoder-php/geocoder`) to avoid dependency errors.
- How do I handle API failures or rate limits in production?
- Implement retries with exponential backoff for transient failures. For rate limits, use Laravel queues to batch geocoding jobs and cache results (e.g., Redis). Consider fallback providers like OpenStreetMap.
- Does this package support async geocoding for performance?
- Yes, dispatch geocoding tasks to Laravel queues (e.g., `Geocoder::geocodeQuery()->onQueue('geocoding')`) to avoid blocking HTTP requests. Process results via job events or database listeners.
- How secure is storing the Bing Maps API key in Laravel?
- Store the key in `.env` (never in code) and restrict file permissions. Rotate keys periodically. For added security, use Laravel’s `env()` helper or a dedicated secrets manager.
- What alternatives exist if Bing Maps isn’t suitable for my project?
- Consider `geocoder-php/google-maps-provider` (Google Maps), `geocoder-php/openstreetmap-provider` (free/open-source), or `geocoder-php/here-provider` (HERE Maps). Each has trade-offs in cost, accuracy, and coverage.
- How do I test geocoding functionality in Laravel?
- Mock the `BingMapsProvider` in unit tests using PHPUnit’s mocking tools. Test edge cases like invalid addresses, rate limits, and API errors. Use `Geocoder::geocodeQuery()` in tests with hardcoded responses.
- Will this package work with Laravel’s service container for dependency injection?
- Yes, the package integrates natively with Laravel’s container. Bind the geocoder instance in `AppServiceProvider` or use the facade (`Geocoder::geocode()`) directly. No manual DI setup is required.