PHP code example of mustafakucuk / google-places

1. Go to this page and download the library: Download mustafakucuk/google-places library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mustafakucuk / google-places example snippets


use GooglePlaces\Client;

$client = new Client('your_api_key_here');

$location = '37.7749,-122.4194'; // Latitude, Longitude
$radius = 500; // Radius in meters
$params = [
    'us, $params);
print_r($places);

$place_id = 'ChIJlYL0Wa-BhYARJi6qr49Ncv1';
$fields = ['displayName', 'id', 'googleMapsUri', 'formattedAddress'];

$place_details = $client->get_place($place_id, $fields);
print_r($place_details);

$query = 'restaurants in Sydney';
$fields = ['places.id', 'places.displayName'];

$places = $client->search_text($query, $fields);
print_r($places);

$input = 'Pizza';
$params = [
    'plete($input, $params);
print_r($suggestions);

try {
    $places = $client->near_by_search($location, $radius, $params);
} catch (\Exception $e) {
    // Handle errors
}