google-places-for-laravel maintained by roundly-consulting
Google Places for Laravel
Google's Places API (New), Routes API and Geocoding API from Laravel: autocomplete, place details, text and nearby search, geocoding, distances and photos through one typed client with fluent query objects, field masks, caching, rate limiting and a first-class fake for tests.
Installation
Requires PHP 8.4, Laravel 12 or 13, and a Google Maps Platform API key with the Places API (New), Routes API and Geocoding API enabled.
composer require roundly-consulting/google-places-for-laravel
Set GOOGLE_PLACES_API_KEY in .env; without it, calls throw PlacesException before any
request is sent.
Usage
Suggest places while the user types, then look up the chosen one:
use RoundlyConsulting\GooglePlaces\Facades\GooglePlaces;
$predictions = GooglePlaces::autocomplete('Luxury Restaurant'); // Collection<AutocompletePrediction>
$place = GooglePlaces::details($predictions->first()->placeId); // ?Place
$place->name;
$place->formattedAddress;
$place->coordinates(); // ?Location
$place->isOpenNow();
$photoUrl = GooglePlaces::photo($place->photos[0], maxWidth: 800)->url(); // key-free, safe for the browser
Search with filters and measure the trip:
use RoundlyConsulting\GooglePlaces\DataTransferObjects\{DistanceQuery, Location, TextSearchQuery};
use RoundlyConsulting\GooglePlaces\Enums\TravelMode;
$brunch = GooglePlaces::textSearch(
(new TextSearchQuery('vegan brunch'))->openNow()->withMinRating(4.0)->take(10),
); // Collection<Place>
$trip = GooglePlaces::distance(new DistanceQuery(
from: new Location(48.1486, 17.1077), // Bratislava
to: new Location(48.2082, 16.3738), // Vienna
type: TravelMode::Driving,
));
$trip->humanReadableDistance; // "79.8 km"
$trip->humanReadableDuration; // "1h 5m"
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/google-places-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). Please see License File for more information.