Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Algolia Places Provider

Algolia Places Provider Laravel Package

geocoder-php/algolia-places-provider

Algolia Places provider for PHP Geocoder. Geocode and reverse geocode using Algolia’s Places API with optional authentication, locale-aware queries, and PSR-18 HTTP clients. Install via Composer and use with StatefulGeocoder for localized results.

View on GitHub
Deep Wiki
Context7

[READ ONLY] Provider for AlgoliaPlaces

Frequently asked questions about Algolia Places Provider
How do I install the Algolia Places provider in a Laravel project?
Run `composer require geocoder-php/algolia-places-provider` to install the package. No Laravel-specific dependencies exist, so it integrates directly with the Geocoder PHP library. Use it alongside Laravel’s ServiceProvider or standalone in your application logic.
Does this provider work with Laravel’s Eloquent spatial queries?
Yes, this provider returns coordinates (latitude/longitude) in standard Geocoder PHP format, which you can store in Laravel models using `point` or `geometry` columns (PostgreSQL). Combine it with packages like `spatie/laravel-geo` for seamless Eloquent geospatial queries.
What Laravel versions are supported by this package?
The package itself has no Laravel-specific dependencies, so it works with any Laravel 5.5+ version. Ensure your project uses PHP 7.2+ and the `geocoder-php/geocoder` library (v4+ recommended) for compatibility.
How do I handle Algolia API authentication in Laravel?
Pass your Algolia `APP_ID` and `API_KEY` to the provider constructor: `new AlgoliaPlaces($httpClient, 'your_app_id', 'your_api_key')`. Store credentials securely in Laravel’s `.env` file and inject them via dependency injection or a ServiceProvider.
Can I use this for address autocomplete in a Laravel app?
Absolutely. Algolia Places excels at search-as-you-type functionality. Use the `geocodeQuery()` method with a `GeocodeQuery` object to fetch suggestions, then render them in a frontend framework like Livewire or Alpine.js for real-time updates.
What’s the best way to cache responses to avoid hitting Algolia’s rate limits?
Cache responses aggressively using Laravel’s cache drivers (Redis or Memcached recommended). Store results for 5–30 minutes with a TTL, as address data changes infrequently. Example: `Cache::remember('geocode_'.$query, 30*60, fn() => $geocoder->geocodeQuery($query)->fetch());`
Are there alternatives if Algolia’s free tier isn’t enough?
Yes. Consider the official Algolia PHP SDK for direct integration, or switch to other Geocoder providers like `geocoder-php/google-maps-provider` (paid) or `geocoder-php/openstreetmap-provider` (free, but slower). Evaluate cost, accuracy, and latency for your use case.
How do I test this provider in a Laravel application?
Mock the Algolia HTTP client in your tests (e.g., using `mockery` or Laravel’s HTTP testing tools). Verify geocoding/reverse geocoding by asserting returned coordinates or address components. Example: `assertEquals(40.7128, $result->getCoordinates()->getLatitude());`
Will this work in production with high traffic?
Yes, but monitor Algolia’s rate limits (100k/month on paid plans). Implement caching (Redis) and consider upgrading to Algolia’s higher-tier plans if you exceed 10k/month requests. Test under load with tools like Laravel Dusk or Artisan commands.
Is there a way to restrict geocoding to specific countries or languages?
Yes. Use the `withLocale()` method (e.g., `fr-FR` for France) and Algolia’s `aroundLatLng` or `aroundRadius` parameters for regional filtering. Example: `GeocodeQuery::create('Paris')->withLocale('fr-FR')->withAroundLatLng(48.8566, 2.3522)->withRadius(50)`.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor