PHPackages                             skagarwal/google-places-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. skagarwal/google-places-api

ActiveLibrary[API Development](/categories/api)

skagarwal/google-places-api
===========================

Google Places Api

3.2.0(10y ago)1913.0M—9.4%47[1 issues](https://github.com/SachinAgarwal1337/google-places-api/issues)7MITPHPPHP ^8.1CI passing

Since Feb 5Pushed 1mo ago9 watchersCompare

[ Source](https://github.com/SachinAgarwal1337/google-places-api)[ Packagist](https://packagist.org/packages/skagarwal/google-places-api)[ Fund](https://www.buymeacoffee.com/sachin1337)[ GitHub Sponsors](https://github.com/SachinAgarwal1337)[ RSS](/packages/skagarwal-google-places-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (30)Used By (7)

[![Latest Stable Version](https://camo.githubusercontent.com/2d431c5b9ff771586ef3cdc65474e2186f40bce0ed2d370a49d15a3fb8c58d9b/68747470733a2f2f706f7365722e707567782e6f72672f736b6167617277616c2f676f6f676c652d706c616365732d6170692f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/skagarwal/google-places-api)[![Total Downloads](https://camo.githubusercontent.com/fe5bdf66d1407b65aad4dfdc5ee44a80eb20284c47effb9eff9607a4691b55d6/68747470733a2f2f706f7365722e707567782e6f72672f736b6167617277616c2f676f6f676c652d706c616365732d6170692f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/skagarwal/google-places-api)[![License](https://camo.githubusercontent.com/3b8ef3536e38d12e5f4f684fb82e8935bbf352b67fd36c5c5baad75d12e449b3/68747470733a2f2f706f7365722e707567782e6f72672f736b6167617277616c2f676f6f676c652d706c616365732d6170692f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/skagarwal/google-places-api)

Google Places API for PHP
=========================

[](#google-places-api-for-php)

A PHP wrapper for **Google Places API Web Service**, compatible with [Laravel](https://laravel.com).

Version Compatibility
---------------------

[](#version-compatibility)

Package VersionPHPLaravelGoogle Places API^3.0^8.1^10 | ^11[Places API](https://developers.google.com/places/web-service/search) and [Places API (New)](https://developers.google.com/maps/documentation/places/web-service/op-overview)^2.2^8.0.2^9 | ^10 | ^11[Places API](https://developers.google.com/places/web-service/search)Caution

Version 3 is a complete rewrite using [Saloon](https://docs.saloon.dev/) with breaking changes.
v2.2 API is deprecated and will be removed in next major version. Which means it is backward compatible.
And it is recommended to shift to v3 API before next major release.
You can refer to v2.2 documentation [here](README-Legacy.md).

Installation
------------

[](#installation)

Install it with composer

```
composer require skagarwal/google-places-api

```

General Usage
-------------

[](#general-usage)

**Laravel user can see the [Laravel Usage](#laravel-usage) section**

```
use SKAgarwal\GoogleApi\PlacesNew\GooglePlaces;

public function foo() {
  $response = GooglePlaces::make(key: 'API KEY', verifySSL: false, throwOnError: false)->autocomplete('some input');

  $data = $response->array();
}
```

> You can also set the **API KEY** after initiating the class using `GooglePlaces::make()->setKey('KEY')` method.

---

Laravel
-------

[](#laravel)

### Step 1

[](#step-1)

publish the config file with following artisan command

```
php artisan vendor:publish --provider="SKAgarwal\GoogleApi\ServiceProvider"

```

This will create **[google.php](config/google.php)** file in the config directory.

Set the ***API* KEY** in this config file.

### Step 2

[](#step-2)

Start making requests

```
use SKAgarwal\GoogleApi\PlacesNew\GooglePlaces;

public function foo() {
  $response = GooglePlaces::make()->autocomplete('some input');

  $data = $response->collect();
}
```

---

Response
========

[](#response)

The response returned is a [Saloon's Response](https://docs.saloon.dev/the-basics/responses#useful-methods) thus you can use all the methods provided by Saloon.

```
$response->array(); // returns the response as array
$response->collect(); // returns the response as collection
$response->json(); // returns the response as json
$response->status(); // returns the status of the response
$response->headers(); // returns the headers of the response
$response->body(); // returns the body of the response
$response->throw(); // throws an exception if the response is not successful
```

You can refer to Saloon's documentation for more methods.

Important

By default, no exception is thrown for API errors. You can check the request status with `$response->status()`.
You can also use `GooglePlaces::make()->findPlace()->throw()` to throw an exception if the request fails.

---

API Reference
=============

[](#api-reference)

This library supports both the **[Places API (original)](#places-original)** and the **[Places API (New)](#places-new)**.

Places API
----------

[](#places-api)

This section covers methods available for original Places API.

```
use SKAgarwal\GoogleApi\Places\GooglePlaces; // Original Places API class

public function foo() {
  $response = GooglePlaces::make()->nearbySearch('40.748817,-73.985428');

  $data = $response->array();
}
```

### Place Search

[](#place-search)

#### `findPlace(string $input, string $inputType, array $params = [])`

[](#findplacestring-input-string-inputtype-array-params--)

- **$input**: Text to search (e.g., name, address).
- **$inputType**: `textquery` or `phonenumber`.
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/search-find-place).

#### `nearbySearch(string $location, ?string $radius = null, array $params = [])`

[](#nearbysearchstring-location-string-radius--null-array-params--)

- **$location**: Latitude,Longitude coordinates. Order - (lat,lng) (e.g., `40.748817,-73.985428`).
- **$radius**: Distance in meters (max 50,000). Required unless using `rankby=distance`.
- **$params**: Optional parameters (e.g., `keyword`, `type`). [More info](https://developers.google.com/maps/documentation/places/web-service/search-nearby).

#### `textSearch(string $query, array $params = [])`

[](#textsearchstring-query-array-params--)

- **$query**: Search string (e.g., `"restaurant"`).
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/search-text).

---

### Place Details

[](#place-details)

#### `placeDetails(string $placeId, array $params = [])`

[](#placedetailsstring-placeid-array-params--)

- **$placeId**: Unique identifier for a place.
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/details).

---

### Place Autocomplete

[](#place-autocomplete)

#### `placeAutocomplete(string $input, array $params = [])`

[](#placeautocompletestring-input-array-params--)

- **$input**: Text to search (e.g., name, address).
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/autocomplete).

---

### Query Autocomplete

[](#query-autocomplete)

#### `queryAutocomplete(string $input, array $params = [])`

[](#queryautocompletestring-input-array-params--)

- **$input**: Text to search (e.g., name, address).
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/query).

---

### Place Photo

[](#place-photo)

#### `photo(string $photoReference, array $params = [])`

[](#photostring-photoreference-array-params--)

- **$photoReference**: Reference to a photo. [More info](https://developers.google.com/maps/documentation/places/web-service/photos#photo_references)
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/photos).

---

Places API (New)
----------------

[](#places-api-new)

This section covers methods available for Places API (New).

```
use SKAgarwal\GoogleApi\PlacesNew\GooglePlaces; // New Places API class

public function foo() {
  $response = GooglePlaces::make()->nearbySearch(40.748817, -73.985428, 500.0);

  $data = $response->array();
}
```

---

### Autocomplete

[](#autocomplete)

#### `autocomplete(string $input, bool $includeQueryPredictions = false, ?array $fields = null, array $params = [])`

[](#autocompletestring-input-bool-includequerypredictions--false-array-fields--null-array-params--)

- **$input**: Text to search (e.g., name, address).
- **$fields**: Fields to return. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).
- **$includeQueryPredictions**: If `true`, the response includes both place and query predictions. The default value is **false**, meaning the response only includes place predictions.
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete).

### Nearby Search

[](#nearby-search)

#### `nearbySearch(float $latitude, float $longitude, float $radius = 0.0, array $fields = ['*'], array $params = [])`

[](#nearbysearchfloat-latitude-float-longitude-float-radius--00-array-fields---array-params--)

- **$latitude**: Latitude of the location.
- **$longitude**: Longitude of the location.
- **$radius**: The radius must be between **0.0** and **50000.0**, inclusive. The default radius is 0.0. You must set it in your request to a value greater than 0.0.
- **$fields**: Fields to return. Default is all fields. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/nearby-search).

### Place Details

[](#place-details-1)

#### `placeDetails(string $placeId, array $fields = ['*'], array $params = [])`

[](#placedetailsstring-placeid-array-fields---array-params--)

- **$placeId**: Unique identifier for a place.
- **$fields**: Fields to return. Default is all fields. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/place-details).

### Text Search

[](#text-search)

#### `textSearch(string $textQuery, array $fields = ['*'], array $params = [])`

[](#textsearchstring-textquery-array-fields---array-params--)

- **$textQuery**: Search string (e.g., `"restaurant"`).
- **$fields**: Fields to return. Default is all fields. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).
- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/text-search).

### Place Photo

[](#place-photo-1)

#### `placePhoto(string $name, int $maxHeightPx = null, int $maxWidthPx = null)`

[](#placephotostring-name-int-maxheightpx--null-int-maxwidthpx--null)

- **$name**: A string identifier that uniquely identifies a photo. [More Info](https://developers.google.com/maps/documentation/places/web-service/place-photos#photo-name)
- **$maxHeightPx**: The maximum desired height of the image in pixels. (Should be between 1 and 4800)
- **$maxWidthPx**: The maximum desired width of the image in pixels. (Should be between 1 and 4800)

> [skipHttpRedirect](https://developers.google.com/maps/documentation/places/web-service/place-photos#skiphttpredirect) is set to false internally to get JSON response. This cannot be changed

---

Custom Headers
==============

[](#custom-headers)

#### Set Custom Headers

[](#set-custom-headers)

```
GooglePlaces::make()->headers()->add('Header-Key', 'Header-Value');
```

---

Additional Methods
==================

[](#additional-methods)

- **`setKey(string $key)`**: Set the API key.
- **`getKey(string $key)`**: Get the API key being used.
- **`verifySSL(bool $verifySSL = true)`**: Enable/disable SSL verification.
- **`throwOnErrors(bool $throwOnError)`**:
    - By default, no exception is thrown for API errors. You can check the request status with `$response->status()`.
    - When `throwOnError` is set to `true`, the library will throw exceptions on API failures.

---

Contribution
============

[](#contribution)

- Report issues or contribute to the `develop` branch.
- Open issues/PRs to improve this documentation.

---

License
=======

[](#license)

This package is licensed under the [MIT License](http://opensource.org/licenses/MIT).

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance59

Moderate activity, may be stable

Popularity61

Solid adoption and visibility

Community32

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 82.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

28

Last Release

3756d ago

Major Versions

1.7.2 → 2.0.02016-02-05

2.2.0 → 3.0.02016-02-05

PHP version history (7 changes)1.0.0PHP &gt;=5.5.9

1.5.0PHP ^5.5.9|^7.2

1.7.1PHP ^5.5.9|^7.2|^7.3

1.7.2PHP ^5.5.9|^7.2|^7.3|^8.0

2.0.0PHP ^7.2.5|^8.0

2.2.0PHP ^8.0.2

3.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/4fdc9ed9a1cff68a494c5c31b171fd86cd80600fccf312cc36458078b6edcd35?d=identicon)[Sachin Agarwal](/maintainers/Sachin%20Agarwal)

---

Top Contributors

[![SachinAgarwal1337](https://avatars.githubusercontent.com/u/5370915?v=4)](https://github.com/SachinAgarwal1337 "SachinAgarwal1337 (72 commits)")[![jhnferraris](https://avatars.githubusercontent.com/u/3207153?v=4)](https://github.com/jhnferraris "jhnferraris (4 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![cino](https://avatars.githubusercontent.com/u/2735602?v=4)](https://github.com/cino "cino (1 commits)")[![kevindierkx](https://avatars.githubusercontent.com/u/2406615?v=4)](https://github.com/kevindierkx "kevindierkx (1 commits)")[![morrislaptop](https://avatars.githubusercontent.com/u/67807?v=4)](https://github.com/morrislaptop "morrislaptop (1 commits)")[![abiodunjames](https://avatars.githubusercontent.com/u/14722744?v=4)](https://github.com/abiodunjames "abiodunjames (1 commits)")[![Sammyjo20](https://avatars.githubusercontent.com/u/29132017?v=4)](https://github.com/Sammyjo20 "Sammyjo20 (1 commits)")[![aminal](https://avatars.githubusercontent.com/u/581445?v=4)](https://github.com/aminal "aminal (1 commits)")[![aozisik](https://avatars.githubusercontent.com/u/735011?v=4)](https://github.com/aozisik "aozisik (1 commits)")

---

Tags

googlegoogle-apigoogle-placesgoogle-places-apilaravellaravel-google-placeslaravel-google-places-apiplacesgooglegoogle apiplacesgoogle placesGoogle Places Api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/skagarwal-google-places-api/health.svg)

```
[![Health](https://phpackages.com/badges/skagarwal-google-places-api/health.svg)](https://phpackages.com/packages/skagarwal-google-places-api)
```

###  Alternatives

[x-fran/g-trends

Google Trends API for PHP

11955.6k](/packages/x-fran-g-trends)[biscolab/google-maps-php-sdk

Google Maps PHP SDK.

14215.1k](/packages/biscolab-google-maps-php-sdk)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[geckob/firebase

PHP package for Firebase wrapper

4251.9k](/packages/geckob-firebase)[tomshaw/google-api

A Laravel Google API Client.

591.5k](/packages/tomshaw-google-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
