Open source
Google Places for Laravel
composer require roundly-consulting/google-places-for-laravelOverview
A typed Laravel client for Google’s Places API (New), Routes API and Geocoding API. Autocomplete addresses, look up and search places, geocode in both directions, compute travel distances, times and full matrices, and fetch place photos — all through one facade that returns clean data objects instead of raw JSON. Built on Laravel’s own HTTP client with no Google SDK, MIT-licensed, and its only other dependencies are four small Roundly packages. A first-class GooglePlaces::fake() keeps your test suite off the paid API.
What you get
Places API (New)
Autocomplete, place details, text and nearby search and find place on Google’s current-generation Places API — header auth and field masks included.
Geocoding both ways
Reverse-geocode coordinates or forward-geocode addresses, then read street, city, postcode and country through typed accessors.
Distance, ETA & matrix
Traffic-aware distance and travel time on the Routes API, one trip per destination from a single origin, and full origins × destinations matrices.
Key-safe photos
Fetch place photo bytes, save them to any Laravel disk, or hand the browser a key-free media URL.
Cost-aware & resilient
Trimmable field masks, billing sessions, opt-in caching, a pagination cap, per-API rate limiting, timeouts and connection retries.
Facade or injected client
Call GooglePlaces::… or inject the PlacesClient contract — GooglePlaces::fake() records every call from either, with no paid traffic.
Observable
Lifecycle events for every request, opt-in request logging, and a health check as code or a preflight command.
Documentation
Installation
Install via Composer, add your Google API key, optionally publish the config and verify the setup with one command.
Configuration
Every config key and env variable — API key, hosts, field masks, timeouts, caching, pagination, logging and per-API rate limits.
The GooglePlaces facade
Every lookup, handle and health check on one facade — scalar shorthands or immutable query objects, and GooglePlaces::fake() for tests.
Without the facade
Inject the PlacesClient contract for the same API without static calls — google-places has no action classes; the client methods are the use cases.
Autocomplete
Place predictions as the user types — types, regions, location bias or restriction, and billing sessions that cut autocomplete costs.
Place details
Fetch a place by id — name, address, coordinates, types, opening hours and photos — with per-request field masks and helpers.
Search & find place
Text search, nearby search and find place — with filters, location bias, page tokens and lazy auto-pagination under a safety cap.
Geocoding
Reverse-geocode coordinates, forward-geocode addresses, and read street, city, postcode and country through typed accessors.
Distance & travel time
Distance and ETA on the Routes API — four travel modes, traffic-aware driving, and one trip per destination from a single origin.
Distance matrix
Compute many origins against many destinations in one call and index every pair, row or column of the result.
Photos
Build photo media URLs, or fetch photo bytes server-side, save them to any disk and get a key-free URL for the browser.
Error handling
One PlacesException with typed checks for rate limits, denied keys, invalid requests and unreachable APIs — the key is redacted from every message.
Caching
Opt-in response caching for idempotent lookups to cut latency and Google spend — safe cache keys, and a not-found is remembered too.
Events & logging
One lifecycle event per request sent to Google and opt-in request logging — for metrics, alerting and audits, without ever exposing the key.
Rate limiting
Every outbound call is paced per Google API on its own budget — adaptive to 429s, tunable by env, with an opt-in fail-fast mode.
Validation rules
Drop-in Laravel rules to check that a place id or a latitude/longitude pair is well-formed before you call Google.
Geolocation driver
Use Google Places as a google_places driver in geolocation-for-laravel for address and coordinate lookups — failures fall through, never abort.
Artisan commands
A preflight check that probes each Google API with your key — as a command or GooglePlaces::check() — plus a section in php artisan about.
Testing
GooglePlaces::fake() records every call and answers from seeded results — assert what your code asked Google, with no paid API traffic.
Requirements
PHP 8.4+, Laravel 12 or 13, and a Google Maps Platform key with the Places, Routes and Geocoding APIs enabled.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.