- How do I add PickPoint geocoding to my Laravel app?
- Install the provider via Composer: `composer require geocoder-php/pickpoint-provider`, then configure it in `config/geocoder.php` under the `providers` key with your PickPoint API key. Register it in your `AppServiceProvider` using `Geocoder::create()->registerProvider()`.
- Does this work with Laravel 9+ and PHP 8.1+?
- Yes, the provider is fully compatible with Laravel 9+ and PHP 8.1+. It leverages PSR-18 HTTP clients (like Guzzle or Symfony’s HTTP client), which are natively supported in modern Laravel. Ensure your `geocoder-php/geocoder` package is version 5.x.
- Can I use PickPoint for reverse geocoding (coordinates to address)?
- Yes, the provider supports both geocoding (address to coordinates) and reverse geocoding (coordinates to address) via the standard Geocoder interface. Use `$geocoder->reverse($latitude, $longitude)` for reverse lookups.
- What if PickPoint’s API fails or has rate limits?
- Implement a fallback provider (e.g., OpenStreetMap) in your `config/geocoder.php` under `providers` with a priority order. Use Laravel’s caching (Redis) to store responses and reduce API calls. Monitor errors via Laravel’s exception handler.
- How do I cache results to avoid hitting PickPoint’s API repeatedly?
- Configure caching in your Geocoder instance by adding a cache adapter (e.g., Redis) during initialization: `Geocoder::create()->registerProvider(...)->setCache(new RedisCacheAdapter())`. Set a TTL (e.g., 1 hour) for static addresses like delivery hubs.
- Is PickPoint better than Google Maps or OpenStreetMap for logistics?
- PickPoint specializes in parcel locker and delivery hub geocoding, making it ideal for last-mile logistics. Compare its pricing and accuracy with alternatives like Google Maps (paid) or OpenStreetMap (free) via `geocoder-php/openstreetmap-provider`. Test with your use case.
- How do I handle API key rotation or security in Laravel?
- Store your PickPoint API key in Laravel’s `.env` file (e.g., `PICKPOINT_API_KEY`). Use Laravel’s `config('geocoder.providers.pickpoint.key')` to fetch it securely. Rotate keys by updating the `.env` and restarting your app or using a service like Laravel Forge.
- Can I use this provider in a Laravel Lumen or API-only app?
- Yes, the provider works in Lumen and API-only Laravel apps. Register it in your service container the same way: `Geocoder::create()->registerProvider(new PickPointProvider($apiKey))`. Ensure your HTTP client (e.g., Guzzle) is PSR-18 compliant.
- What happens if PickPoint’s API changes or deprecates endpoints?
- Monitor the [geocoder-php/pickpoint-provider GitHub repo](https://github.com/geocoder-php/pickpoint-provider) for updates. Use `composer why-not` to check compatibility before updating. Implement a fallback provider to avoid downtime during transitions.
- How do I test this provider in my CI/CD pipeline?
- Mock PickPoint API responses using Laravel’s HTTP testing or a library like VCR. Test edge cases like invalid addresses, rate limits, and API failures. Example: `Geocoder::create()->registerProvider(new PickPointProvider($mockKey))->geocode('invalid')` and assert exceptions.