1. Go to this page and download the library: Download ipowerful/googleplace 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/ */
$rankBy = new \GooglePlace\Services\Nearby([
'location' => '23.823168,90.367728',
'rankby' => 'distance',
'type' => 'bank'
]
);
$rankBy->places(); // it will return \Collection each contains a object of GooglePlace\Services\Place
/* Google Return 60 places divide by 20 each request.
To get next 20 result you have to call nextPage method.
*/
print_r($rankBy->nextPage()); // it will return \GooglePlace\Response
$textSearch = new \GooglePlace\Services\TextSearch([
'query' => 'Restaurants in Mirpur'
]);
$places = $textSearch->places(); //same as nearby
$place=new \GooglePlace\Services\Place([
'placeid'=>'any place id'
]);
$place->get();
echo $place->address();
echo $place->phone();
print_r($place->photos()); // returns Collection each contains a GooglePlace\Helpers\PlacePhoto object
print_r($place->reviews()); // return Collection
print_r($place->timezone(true)); // return Timezone API response
print_r($place->distance($place2)); // return Distance Matrix API response
print_r($place->elevation()); // return Elevation API response
$geocoding = new \GooglePlace\Services\Geocoding([
'address' => 'House 13,Road 10,Section 11,Mirpur,Dhaka'
]);
print_r($geocoding->places());
$reverseGeocoding= new \GooglePlace\Services\Geocoding([
'address' => 'latlng' => '23.8163589,90.3709893'
]);
print_r($reverseGeocoding->places()); //same as nearby
$distanceMatrix = new \GooglePlace\Services\DistanceMatrix([
'origins' => ['Dhaka University, Dhaka'],
'destinations' => ['National University of Bangldesh, Gazipur']]);
print_r($distanceMatrix->calculate());