PHPackages                             m1n64/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. m1n64/google-places-api

ActiveLibrary[API Development](/categories/api)

m1n64/google-places-api
=======================

Google Places Api

2.3.0(10y ago)08MITPHPPHP ^7.2.5|^8.0

Since Feb 5Pushed 3y agoCompare

[ Source](https://github.com/m1n64/google-places-api)[ Packagist](https://packagist.org/packages/m1n64/google-places-api)[ RSS](/packages/m1n64-google-places-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (25)Used By (0)

Google Places API.
==================

[](#google-places-api)

This is a PHP wrapper for **Google Places API Web Service**

About Package
-------------

[](#about-package)

With just 2 lines of code you can request to any google places api feature. No need to manually perform any curl requests.

### The following place requests are available:

[](#the-following-place-requests-are-available)

- [Place Search](#place-search) This service gives a list of places based on a user's location or search string.
- [Place Details](#place-details) This service gives more detailed information about a specific Place, including user reviews.
- [Place Autocomplete](#place-autocomplete) This service is Used to automatically fill in the name and/or address of a place as you type.
- [Query Autocomplete](#query-autocomplete) This service is Used to provide a query prediction service for text-based geographic searches, by returning suggested queries as you type.
- [Place Photo](#place-photo) This gives you access to the millions of photos stored in the Google's Places database
- [Custom Headers](#custom-headers) Set Custom Headers.
- [Additional Methods](#additional-methods) Additional Methods Available.

Installation
============

[](#installation)

Install it with composer

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

```

Usage
=====

[](#usage)

Step 1 - Import the class using namespace
-----------------------------------------

[](#step-1---import-the-class-using-namespace)

```
use SKAgarwal\GoogleApi\PlacesApi;
```

Step 2 - Initiate the object
----------------------------

[](#step-2---initiate-the-object)

```
$googlePlaces = new PlacesApi('API KEY');
```

**Note:** You can also set the **API KEY** after initiating the class using `setKey('KEY')` method. You can chain this with method with any other methods.

Step 3 - Start Using the Api.
-----------------------------

[](#step-3---start-using-the-api)

Example:

```
$response = $googlePlaces->placeAutocomplete('some Place');
```

As mentioned earlier just 2 lines of code to make any request.

**Full example:**

```
use SKAgarwal\GoogleApi\PlacesApi;

function () {
  $googlePlaces = new PlacesApi('API_KEY') # line 1
  $response = $googlePlaces->placeAutocomplete('some input'); # line 2
}
```

---

Response
========

[](#response)

The response returned is a [Laravel's Collection](https://laravel.com/docs/5.2/collections) so that you can perform any of the available collection methods on it.

> If you are not familiar with *Laravel's Collection* you can either reference the docs [here](https://laravel.com/docs/5.2/collections) or you can use **response** as simple array.

---

Available Methods
=================

[](#available-methods)

Place Search
------------

[](#place-search)

### nearbySearch($location, $radius = null, $params = \[\])

[](#nearbysearchlocation-radius--null-params--)

- `location` — The latitude/longitude around which to retrieve place information. This must be specified as latitude, longitude.
- 'radius' — Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50 000 meters. Note that `radius` must not be included if `rankby=distance` (described under **Optional parameters** below) is specified.
- If `rankby=distance` (described under **Optional parameters** below) is specified, then one or more of `keyword`, `name`, or `types` is required.
- `params` - **Optional Parameters** You can refer all the available optional parameters on the [Google's Official Webpage](https://developers.google.com/places/web-service/search)

### textSearch($query, $params = \[\])

[](#textsearchquery-params--)

- `query` — The text string on which to search, for example: "restaurant". The Google Places service will return candidate matches based on this string and order the results based on their perceived relevance.
- `params` - **Optional Parameters** You can refer all the available optional parameters on the [Google's Official Webpage](https://developers.google.com/places/web-service/search)

### findPlace($input, $inputType, $params = \[\])

[](#findplaceinput-inputtype-params--)

- `input` — The text input specifying which place to search for (for example, a name, address, or phone number).
- `inputType` — The type of input. This can be one of either textquery or phonenumber. Phone numbers must be in international format (prefixed by a plus sign ("+"), followed by the country code, then the phone number itself).
- `params` - **Optional Parameters** You can refer all the available optional parameters on the [Google's Official Webpage](https://developers.google.com/places/web-service/search#FindPlaceRequests)

---

Place Details
=============

[](#place-details)

### placeDetails($placeId, $params = \[\])

[](#placedetailsplaceid-params--)

- `placeId` — A textual identifier that uniquely identifies a place, returned from a Place Search.
- `params` - **Optional Parameters** You can refer all the available optional parameters on the [Google's Official Webpage](https://developers.google.com/places/web-service/details)

---

Place Autocomplete
==================

[](#place-autocomplete)

### placeAutocomplete($input, $params = \[\])

[](#placeautocompleteinput-params--)

- `input` — The text string on which to search. The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance.
- `params` - **Optional Parameters** You can refer all the available optional parameters on the [Google's Official Webpage](https://developers.google.com/places/web-service/autocomplete)

---

Query Autocomplete
==================

[](#query-autocomplete)

### queryAutocomplete($input, $params = \[\])

[](#queryautocompleteinput-params--)

- `input` — The text string on which to search. The Places service will return candidate matches based on this string and order results based on their perceived relevance.
- `params` - **Optional Parameters** You can refer all the available optional parameters on the [Google's Official Webpage](https://developers.google.com/places/web-service/query)

---

Place Photo
===========

[](#place-photo)

### photo($photoReference, $params = \[\])

[](#photophotoreference-params--)

- `params` - The set of key-value parameters necessary to add a place to Google. You can refer to the fields on [Google's Official Webpage regarding Place Add](https://developers.google.com/places/web-service/photos)

---

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

[](#custom-headers)

### withHeaders(array $headers)

[](#withheadersarray-headers)

Call This method before any other methods to set the headers. You can chain this method.

### new PlacesApi($key = null, $verifySSL = true, array $headers = \[\])

[](#new-placesapikey--null-verifyssl--true-array-headers--)

To have custom headers set for every call, you can pass 3rd parameter as the headers to class constructor.

**Note:** For Laravel Users, you can set this in config file with key `headers`

---

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

[](#additional-methods)

### getStatus()

[](#getstatus)

This will return the status of the response send by google api. Use it after making any request.

### getKey()

[](#getkey)

This will return the `API KEY` been used with the requests.

### setKey($key)

[](#setkeykey)

This will set the `API KEY`.

### verifySSL($verifySSL = true)

[](#verifysslverifyssl--true)

You can pass `false` to disable Verification of SSL Certification.

**Note:** For Laravel Users, you can set this in config file with key `verify_ssl`

Or You can Pass the path to the certificate.

Exceptions
==========

[](#exceptions)

Google Places API may throw various exceptions based on the given `$params` or response and is located in the `SKAgarwal\GoogleApi\Exceptions` namespace.

- A `GooglePlacesApiException` is thrown when no `API KEY` is provided or `$params` is invalid. **Note:** This is the parent class for the preceding exceptions.
- A `InvalidRequestException` is thrown when the response `status` is `INVALID_REQUEST`
- A `OverQueryLimitException` is thrown when the response `status` is `OVER_QUERY_LIMIT`
- A `RequestDeniedException` is thrown when the response `status` is `REQUEST_DENIED`
- A `UnknownErrorException` is thrown when the response `status` is `UNKNOWN_ERROR`
- A `NotImplementedException` is thrown when the response cannot be determined.

If any of these exception has been thrown, you can use the `getErrorMessage()` method to get the `error_message` field from the response if any is provided. **Note:** `error_message` field is not guaranteed to be always present, and its content is subject to change.

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

[](#contribution)

Feel free to report issues or make Pull Requests. If you find this document can be improved in any way, please feel free to open an issue for it.

License
=======

[](#license)

The Google Places Api is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 79.7% 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

23

Last Release

3747d ago

Major Versions

1.7.2 → 2.0.02016-02-05

PHP version history (5 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

### Community

Maintainers

![](https://www.gravatar.com/avatar/068f8c26f06f513a9c38d2a01c4d90a85eae1125a5b9d14eae7059715be860e4?d=identicon)[m1n64](/maintainers/m1n64)

---

Top Contributors

[![SachinAgarwal1337](https://avatars.githubusercontent.com/u/5370915?v=4)](https://github.com/SachinAgarwal1337 "SachinAgarwal1337 (51 commits)")[![jhnferraris](https://avatars.githubusercontent.com/u/3207153?v=4)](https://github.com/jhnferraris "jhnferraris (4 commits)")[![m1n64](https://avatars.githubusercontent.com/u/24874264?v=4)](https://github.com/m1n64 "m1n64 (2 commits)")[![cino](https://avatars.githubusercontent.com/u/2735602?v=4)](https://github.com/cino "cino (1 commits)")[![abiodunjames](https://avatars.githubusercontent.com/u/14722744?v=4)](https://github.com/abiodunjames "abiodunjames (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![morrislaptop](https://avatars.githubusercontent.com/u/67807?v=4)](https://github.com/morrislaptop "morrislaptop (1 commits)")[![kevindierkx](https://avatars.githubusercontent.com/u/2406615?v=4)](https://github.com/kevindierkx "kevindierkx (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 apiplacesgoogle placesGoogle Places Api

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[google/apiclient

Client library for Google APIs

9.8k191.4M991](/packages/google-apiclient)[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)[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)
