- How do I install the ArcGIS Online provider in a Laravel 11 project?
- Run `composer require geocoder-php/arcgis-online-provider:^4.5.0` to install. The package requires PHP 8.1+ and Laravel 10/11. No additional Laravel-specific setup is needed beyond registering the provider in your `AppServiceProvider` or wherever you initialize the Geocoder instance.
- Does this package support Laravel’s Eloquent or Scout for geospatial queries?
- No, this package does not integrate directly with Eloquent or Scout. You’ll need to manually map ArcGIS responses (GeoJSON) to your models. For Eloquent support, pair it with Spatie’s Laravel Geotools package, which provides traits like `HasCoordinates` for geospatial queries.
- What Laravel versions and PHP versions does this package support?
- The package supports PHP 8.1+ and Laravel 10/11 LTS. It does not officially support Laravel 9 or earlier. Always pin the version in `composer.json` (e.g., `4.5.0`) to avoid unintended updates, as changelogs are minimal.
- How do I handle authentication for ArcGIS Online in Laravel?
- Store your ArcGIS API key in your `.env` file (e.g., `ARCGIS_API_KEY=your_key_here`). The provider reads this key automatically. For production, encrypt the key using Laravel’s encryption or a secrets manager like HashiCorp Vault to avoid hardcoding.
- Can I use this for batch geocoding in Laravel?
- The package itself doesn’t support batch processing natively, but you can integrate it with Laravel Queues or Horizon for async jobs. Use Laravel’s `BatchHandler` or chunk queries to process large datasets efficiently. Caching responses (e.g., with Redis) is highly recommended to reduce API calls.
- What happens if ArcGIS Online’s API rate limits are exceeded?
- The package relies on Guzzle for HTTP requests, so you can configure retries and timeouts via Guzzle middleware. Monitor your usage in the ArcGIS dashboard and implement caching (e.g., Redis) to minimize API calls. For high-volume apps, consider fallback providers like Google Maps or Nominatim.
- Is there a built-in caching layer for geocoding results?
- No, the package does not include caching. You must integrate Laravel’s cache (Redis, Memcached) or use the `geocoder-php` cache providers (e.g., `CacheProvider`). Cache responses by coordinates or addresses to avoid redundant API calls and reduce costs.
- Are there alternatives to this package for Laravel geocoding?
- Yes, alternatives include the `geocoder-php/google-maps-provider` (for Google Maps) or `geocoder-php/nominatim-provider` (free, OpenStreetMap-based). For ArcGIS, this is the only official provider, but you could also use the base `geocoder-php/geocoder` with a custom ArcGIS HTTP client if needed.
- How do I test this package in a Laravel application?
- Mock the ArcGIS API responses in your tests using Laravel’s HTTP testing or a library like VCR. Test edge cases like invalid addresses, rate limits, and authentication failures. Use PHPUnit to verify the Geocoder instance is properly configured and responses are parsed correctly.
- What are the production concerns when using ArcGIS Online in Laravel?
- Key concerns include API rate limits, cost management, and data privacy (e.g., GDPR compliance). Monitor usage via ArcGIS’s dashboard, implement caching, and encrypt API keys. For offline use, consider PostGIS or local geocoding solutions to reduce dependency on ArcGIS.