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

ActiveLibrary[API Development](/categories/api)

flarone/google-places-api
=========================

Google Places Api

1.0.1(3y ago)19MITPHPPHP ^7.2.5|^8.0|^8.1|^8.2

Since Nov 16Pushed 3y agoCompare

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

READMEChangelogDependencies (5)Versions (4)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/10f3af8fc987e1c44e7410ca2939c76efb7cb8b33b297fafe7baab759b14bb40/68747470733a2f2f706f7365722e707567782e6f72672f666c61726f6e652f676f6f676c652d706c616365732d6170692f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/flarone/google-places-api)[![Latest Unstable Version](https://camo.githubusercontent.com/e8ac139ad77c5bdceac80a3b2fc679d92536c94801d806ed8caeedcf8969c904/68747470733a2f2f706f7365722e707567782e6f72672f666c61726f6e652f676f6f676c652d706c616365732d6170692f762f756e737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/flarone/google-places-api)[![Total Downloads](https://camo.githubusercontent.com/817da73c0dc79ac6fad3c1a4d16dce641e83bbcb690b154ff8b73078d6e875d3/68747470733a2f2f706f7365722e707567782e6f72672f666c61726f6e652f676f6f676c652d706c616365732d6170692f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/flarone/google-places-api)[![License](https://camo.githubusercontent.com/7d772e090d259f2f845ee0c81e425fc911e79dd7384269c4fce950151f2b8b9a/68747470733a2f2f706f7365722e707567782e6f72672f666c61726f6e652f676f6f676c652d706c616365732d6170692f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/flarone/google-places-api)

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

[](#google-places-api)

This is a PHP wrapper for **Google Places API Web Service**. And is [Laravel Framework](https://laravel.com/docs/9.x) friendly.

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 flarone/google-places-api

```

Usage
=====

[](#usage)

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

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

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

```
use Flarone\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 Flarone\GoogleApi\PlacesApi;

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

---

Use with Laravel
================

[](#use-with-laravel)

For Laravel 5.5 and up
----------------------

[](#for-laravel-55-and-up)

Auto Discovery added.

For Laravel 5.4 and below
-------------------------

[](#for-laravel-54-and-below)

Step 1
------

[](#step-1)

Set up the service provider and facade in the **config\\app.php**

```
'providers' => [
....
....
Flarone\GoogleApi\ServiceProvider::class,
];

'aliases' => [
....
....
'GooglePlaces' => Flarone\GoogleApi\Facade::class,
];
```

Step 2
------

[](#step-2)

publish the config file with following artisan command

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

```

This will create **google.php** file in the config directory.

Set the *API KEY* in this config file.

Set 3
-----

[](#set-3)

Start using the package using Facade.

```
$response = GooglePlaces::placeAutocomplete('some city');

```

---

Response
========

[](#response)

The response returned is a [Laravel's Collection](https://laravel.com/docs/9.x/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/9.x/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 `Flarone\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)

This Google Places Api was forked from `skagarwal/google-places-api`. The Google Places Api is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~122 days

Total

2

Last Release

1152d ago

PHP version history (2 changes)1.0PHP ^7.2.5|^8.0|^8.1

1.0.1PHP ^7.2.5|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/51fd7905d0acba590e8e161f4c10f91eef023650ec78751bb7885ce4e9664df0?d=identicon)[Flarone](/maintainers/Flarone)

---

Top Contributors

[![MarcelWiebenga](https://avatars.githubusercontent.com/u/10196899?v=4)](https://github.com/MarcelWiebenga "MarcelWiebenga (2 commits)")

---

Tags

googlegoogle apiplacesgoogle placesGoogle Places Api

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[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)
