Google places PHP API client.

Google have an API to provide data related place which is call “Google Places”. You can search to the api using different name of the location and also can append services (e.g Burger in Newyork) and it returns matched you keyword, location.

Last year I wrote a wrapper on PHP on top of the API to access it from PHP application.  Used Composer for the first time, as dependency manager for the wrapper.


To use it set the configuration (update the API key of you google place account) and you are ready to go.

require_once 'googleplaces.class.php';
$googlePlaces = new GooglePlaces(array(
'apiKey' => "YOUR_API_KEY"
$query['query'] = "Burger in Berlin";
$places = $googlePlaces->getLocationsByTextSearch($query);
$decoded_data = json_decode($places, true);

Feel free to fork it and contribute 🙂

One comment

  1. dfgdfgdfg · June 5, 2018

    When I tried the example I get this result:

    Warning: Invalid argument supplied for foreach() in C:\wamp64\www\myapp\Utils.php on line 36

    can you advise please as I did not get any response for searching with this url

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.