- How do I install the Yandex provider for Laravel geocoding?
- Run `composer require geocoder-php/yandex-provider` to install. No additional Laravel-specific setup is needed beyond binding the provider to the service container. Follow the [Geocoder PHP docs](https://geocoder-php.org/) for integration with Laravel’s HTTP client or facades.
- Does this package support Laravel’s queue system for async geocoding?
- Yes. Use Laravel’s queue system to offload geocoding jobs (e.g., `geocode:address`). The provider works with any PSR-18 HTTP client, so you can integrate it with Laravel’s `queue:work` or Guzzle middleware for retries.
- What Laravel versions are compatible with geocoder-php/yandex-provider?
- The package supports Laravel 8.x, 9.x, and 10.x. It depends on `geocoder-php/core`, which has no Laravel-specific dependencies. Tested with PHP 8.0+ and follows PSR standards for broad compatibility.
- How do I handle Yandex API rate limits in Laravel?
- Use Laravel’s caching layer (e.g., Redis) to store geocoding results with a TTL (e.g., 5 minutes for static addresses). Implement exponential backoff in your HTTP client middleware or use Guzzle’s retry logic for failed requests.
- Can I use this provider alongside Google Maps or OpenStreetMap in Laravel?
- Absolutely. The package is part of the `geocoder-php` ecosystem, which supports multi-provider fallback. Configure a primary provider (e.g., Yandex) and secondary providers (e.g., Google) in your Laravel service container for high availability.
- How do I configure the Yandex API key in Laravel?
- Store your Yandex API key in `.env` (e.g., `YANDEX_GEOCODE_API_KEY`). Bind the provider in Laravel’s `AppServiceProvider` using the key from config, like this: `$app->bind(Yandex::class, fn() => new Yandex($httpClient, null, config('services.yandex.api_key')));`.
- What languages does the Yandex provider support for geocoding?
- The provider supports Russian (`ru-RU`), Ukrainian (`uk-UA`), Belarusian (`be-BY`), English (`en-US`/`en-BR`), and Turkish (`tr-TR`). Set the locale via the `GeocodeQuery` or `ReverseQuery` constructor for accurate results.
- Is this package suitable for production use in high-traffic Laravel apps?
- Yes, but monitor Yandex’s API usage limits and costs. For high volume, implement batch processing, caching, and fallback providers. Use Laravel’s queue system to distribute geocoding tasks and avoid timeouts.
- How do I test geocoding functionality in Laravel unit tests?
- Mock the `Yandex` provider using Laravel’s `MockHttpClient` or Guzzle’s `MockHandler`. Test edge cases like invalid addresses, coordinates, and API errors. Example: `$mock = new MockHandler([new Response(200, [], json_encode(['results' => [...]]))]);`
- What are the alternatives to geocoder-php/yandex-provider for Laravel?
- Alternatives include `spatie/laravel-geocoder` (Laravel-specific wrapper), `mapbox/geocoder-php`, or `openstreetmap/geocoder-php`. Choose based on region (Yandex excels in CIS/Europe), cost, and API features. Yandex is ideal for Russian/Belarusian addresses.