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

ActiveLibrary[API Development](/categories/api)

mustafakucuk/google-places
==========================

A simple PHP wrapper for the new Google Places API, making it easy to perform place searches, retrieve details, and use autocomplete features.

v1.0.1(1y ago)2362MITPHP

Since Sep 2Pushed 1y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Google Places API (New) API Wrapper (README)
--------------------------------------------

[](#google-places-api-new-api-wrapper-readme)

This PHP wrapper provides an easy-to-use interface for interacting with the Google Places API. It simplifies the process of making API requests for place searches, place details, and autocomplete features. The wrapper handles API authentication, request formatting, and response parsing, allowing developers to integrate Google Places functionality into their PHP applications with minimal effort.

Features
--------

[](#features)

- **Nearby Search**: Search for places near a specified location within a given radius.
- **Place Details**: Retrieve detailed information about a specific place using its place ID.
- **Text Search**: Search for places based on a text query.
- **Autocomplete**: Get place suggestions based on partial user input.

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

[](#installation)

To use this wrapper, you'll need to have [Composer](https://getcomposer.org/) installed.

```
composer require mustafakucuk/google-places

```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

Before you can make any requests, you need to initialize the client with your Google Places API key:

```
use GooglePlaces\Client;

$client = new Client('your_api_key_here');
```

### Nearby Search

[](#nearby-search)

Search for places near a specified location within a given radius:

```
$location = '37.7749,-122.4194'; // Latitude, Longitude
$radius = 500; // Radius in meters
$params = [
    'includedTypes' => ['restaurant'],
    'fields' => ['places.id', 'places.displayName'],
];

$places = $client->near_by_search($location, $radius, $params);
print_r($places);
```

### Place Details

[](#place-details)

Retrieve detailed information about a specific place using its place ID:

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

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

### Text Search

[](#text-search)

Search for places based on a text query:

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

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

### Autocomplete

[](#autocomplete)

Get place suggestions based on partial user input:

```
$input = 'Pizza';
$params = [
    'includedPrimaryTypes' => ['mexican_restaurant'],
];
$suggestions = $client->autocomplete($input, $params);
print_r($suggestions);
```

Methods
-------

[](#methods)

### `prepare_fields(array|string $fields, bool $clean_prefix = false): string`

[](#prepare_fieldsarraystring-fields-bool-clean_prefix--false-string)

Formats and prepares the fields parameter for API requests.

- **$fields**: The fields to be included in the API request. Can be provided as an array or a comma-separated string. Defaults to `'*'` if empty.
- **$clean\_prefix**: Optional. If `true`, removes the `places.` prefix from field names. Defaults to `false`.
- **Returns**: A formatted, comma-separated string of fields.

### `near_by_search(string $location, int $radius, array $params = []): array`

[](#near_by_searchstring-location-int-radius-array-params---array)

Performs a nearby search for places.

- **$location**: A comma-separated string representing the latitude and longitude (e.g., `"37.7749,-122.4194"`).
- **$radius**: The radius (in meters) within which to search for places.
- **$params**: Optional. Additional parameters for the API request.
- **Returns**: An associative array of places.

### `get_place(string $place_id, array $fields = []): array`

[](#get_placestring-place_id-array-fields---array)

Retrieves details about a specific place using its place ID.

- **$place\_id**: The unique identifier of the place.
- **$fields**: Optional. An array of fields to include in the response.
- **Returns**: An associative array with place details.

### `search_text(string $query, array $fields = []): array`

[](#search_textstring-query-array-fields---array)

Performs a text-based search for places.

- **$query**: The search query text.
- **$fields**: Optional. An array of fields to include in the response.
- **Returns**: An associative array of places.

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

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

Provides autocomplete suggestions based on user input.

- **$input**: The partial text input from the user.
- **$params**: Optional. Additional parameters for the API request.
- **Returns**: An array of autocomplete suggestions.

Error Handling
--------------

[](#error-handling)

The wrapper throws exceptions when it encounters errors. Ensure you handle exceptions in your implementation:

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

617d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7347594?v=4)[Mustafa KÜÇÜK](/maintainers/mustafakucuk)[@mustafakucuk](https://github.com/mustafakucuk)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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