{"id":13541384,"url":"https://github.com/SachinAgarwal1337/google-places-api","last_synced_at":"2025-04-02T09:31:52.879Z","repository":{"id":55028919,"uuid":"51136677","full_name":"SachinAgarwal1337/google-places-api","owner":"SachinAgarwal1337","description":"This is a PHP wrapper for Google Places API Web Service. And is Laravel Framework friendly.","archived":false,"fork":false,"pushed_at":"2024-03-11T17:06:00.000Z","size":56,"stargazers_count":180,"open_issues_count":2,"forks_count":45,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-05-05T09:42:23.390Z","etag":null,"topics":["google","google-api","google-places","google-places-api","laravel","laravel-google-places","laravel-google-places-api","places"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SachinAgarwal1337.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-02-05T09:08:31.000Z","updated_at":"2024-04-04T17:54:20.000Z","dependencies_parsed_at":"2024-03-11T18:29:34.826Z","dependency_job_id":"cfe7e92c-211f-43b0-86f1-769f2c63ce98","html_url":"https://github.com/SachinAgarwal1337/google-places-api","commit_stats":{"total_commits":46,"total_committers":12,"mean_commits":"3.8333333333333335","dds":0.4347826086956522,"last_synced_commit":"75b0877ba3618168cf9ae885878cd426db17d0d7"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachinAgarwal1337%2Fgoogle-places-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachinAgarwal1337%2Fgoogle-places-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachinAgarwal1337%2Fgoogle-places-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SachinAgarwal1337%2Fgoogle-places-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SachinAgarwal1337","download_url":"https://codeload.github.com/SachinAgarwal1337/google-places-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246433752,"owners_count":20776655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google","google-api","google-places","google-places-api","laravel","laravel-google-places","laravel-google-places-api","places"],"created_at":"2024-08-01T10:00:45.630Z","updated_at":"2025-04-02T09:31:52.872Z","avatar_url":"https://github.com/SachinAgarwal1337.png","language":"PHP","funding_links":[],"categories":["Popular Packages"],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/skagarwal/google-places-api/v/stable?format=flat-square)](https://packagist.org/packages/skagarwal/google-places-api)\n[![Total Downloads](https://poser.pugx.org/skagarwal/google-places-api/downloads?format=flat-square)](https://packagist.org/packages/skagarwal/google-places-api)\n[![License](https://poser.pugx.org/skagarwal/google-places-api/license?format=flat-square)](https://packagist.org/packages/skagarwal/google-places-api)\n\n# Google Places API for PHP\n\nA PHP wrapper for **Google Places API Web Service**, compatible with [Laravel](https://laravel.com).\n\n## Version Compatibility\n\n| Package Version |  PHP   |     Laravel      | Google Places API                                                                                                                                                           |\n|:---------------:|:------:|:----------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n|      ^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) |\n|      ^2.2       | ^8.0.2 | ^9 \\| ^10 \\| ^11 | [Places API](https://developers.google.com/places/web-service/search)                                                                                                       |\n\n\u003e [!CAUTION]\n\u003e Version 3 is a complete rewrite using [Saloon](https://docs.saloon.dev/) with breaking changes.    \n\u003e v2.2 API is deprecated and will be removed in next major version. Which means it is backward compatible.   \n\u003e And it is recommended to shift to v3 API before next major release.   \n\u003e You can refer to v2.2 documentation [here](README-Legacy.md).\n\n\n## Installation\nInstall it with composer\n```\ncomposer require skagarwal/google-places-api\n```\n\n\n## General Usage\n\n**Laravel user can see the [Laravel Usage](#laravel-usage) section**\n\n```php\nuse SKAgarwal\\GoogleApi\\PlacesNew\\GooglePlaces;\n\n\npublic function foo() {\n  $response = GooglePlaces::make(key: 'API KEY', verifySSL: false, throwOnError: false)-\u003eautocomplete('some input');\n  \n  $data = $response-\u003earray();\n}\n\n```\n\n\u003eYou can also set the **API KEY** after initiating the class using `GooglePlaces::make()-\u003esetKey('KEY')` method.\n\n\n---\n\n\u003ca name=\"laravel-usage\"\u003e\u003c/a\u003e\n## Laravel\n\n\n### Step 1\npublish the config file with following artisan command\n```\nphp artisan vendor:publish --provider=\"SKAgarwal\\GoogleApi\\ServiceProvider\"\n```\n\nThis will create **[google.php](config/google.php)** file in the config directory.\n\nSet the **_API_ KEY** in this config file.\n\n### Step 2\nStart making requests\n\n```php\nuse SKAgarwal\\GoogleApi\\PlacesNew\\GooglePlaces;\n\n\npublic function foo() {\n  $response = GooglePlaces::make()-\u003eautocomplete('some input');\n  \n  $data = $response-\u003ecollect();\n}\n\n```\n\n---\n# Response\n\nThe 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.\n    \n```php\n$response-\u003earray(); // returns the response as array\n$response-\u003ecollect(); // returns the response as collection\n$response-\u003ejson(); // returns the response as json\n$response-\u003estatus(); // returns the status of the response\n$response-\u003eheaders(); // returns the headers of the response\n$response-\u003ebody(); // returns the body of the response\n$response-\u003ethrow(); // throws an exception if the response is not successful\n```\n\nYou can refer to Saloon's documentation for more methods.\n\n\u003e [!IMPORTANT]  \n\u003e By default, no exception is thrown for API errors. You can check the request status with `$response-\u003estatus()`.  \n\u003e You can also use `GooglePlaces::make()-\u003efindPlace()-\u003ethrow()` to throw an exception if the request fails.\n\n---\n\n# API Reference\n\nThis library supports both the **[Places API (original)](#places-original)** and the **[Places API (New)](#places-new)**.\n\n\u003ca name=places-original\u003e\u003c/a\u003e\n## Places API\nThis section covers methods available for original Places API.\n```php\nuse SKAgarwal\\GoogleApi\\Places\\GooglePlaces; // Original Places API class\n\npublic function foo() {\n  $response = GooglePlaces::make()-\u003enearbySearch('40.748817,-73.985428');\n  \n  $data = $response-\u003earray();\n}\n```\n\n### Place Search\n\n#### `findPlace(string $input, string $inputType, array $params = [])`\n- **$input**: Text to search (e.g., name, address).\n- **$inputType**: `textquery` or `phonenumber`.\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/search-find-place).\n\n#### `nearbySearch(string $location, ?string $radius = null, array $params = [])`\n- **$location**: Latitude,Longitude coordinates. Order - (lat,lng) (e.g., `40.748817,-73.985428`).\n- **$radius**: Distance in meters (max 50,000). Required unless using `rankby=distance`.\n- **$params**: Optional parameters (e.g., `keyword`, `type`). [More info](https://developers.google.com/maps/documentation/places/web-service/search-nearby).\n\n#### `textSearch(string $query, array $params = [])`\n- **$query**: Search string (e.g., `\"restaurant\"`).\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/search-text).\n\n---\n\n### Place Details\n\n#### `placeDetails(string $placeId, array $params = [])` \n- **$placeId**: Unique identifier for a place.\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/details).\n\n---\n\n### Place Autocomplete\n#### `placeAutocomplete(string $input, array $params = [])`\n- **$input**: Text to search (e.g., name, address).\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/autocomplete).\n\n---\n\n### Query Autocomplete\n#### `queryAutocomplete(string $input, array $params = [])`\n- **$input**: Text to search (e.g., name, address).\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/query).\n\n---\n\n### Place Photo\n#### `photo(string $photoReference, array $params = [])`\n- **$photoReference**: Reference to a photo. [More info](https://developers.google.com/maps/documentation/places/web-service/photos#photo_references)  \n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/photos).\n\n---\n\u003ca name=places-new\u003e\u003c/a\u003e\n## Places API (New)\n\nThis section covers methods available for Places API (New).   \n\n```php\nuse SKAgarwal\\GoogleApi\\PlacesNew\\GooglePlaces; // New Places API class\n\npublic function foo() {\n  $response = GooglePlaces::make()-\u003enearbySearch(40.748817, -73.985428, 500.0);\n  \n  $data = $response-\u003earray();\n}\n```\n---\n\n### Autocomplete\n#### `autocomplete(string $input, bool $includeQueryPredictions = false, ?array $fields = null, array $params = [])`\n- **$input**: Text to search (e.g., name, address).\n- **$fields**: Fields to return. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).\n- **$includeQueryPredictions**: If `true`, the response includes both place and query predictions. The default value is **false**, meaning the response only includes place predictions.\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/place-autocomplete).\n\n### Nearby Search\n#### `nearbySearch(float $latitude, float $longitude, float $radius = 0.0, array $fields = ['*'], array $params = [])`\n- **$latitude**: Latitude of the location.\n- **$longitude**: Longitude of the location.\n- **$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.\n- **$fields**: Fields to return. Default is all fields. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/nearby-search).\n\n### Place Details\n#### `placeDetails(string $placeId, array $fields = ['*'], array $params = [])`\n- **$placeId**: Unique identifier for a place.\n- **$fields**: Fields to return. Default is all fields. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/place-details).\n\n### Text Search\n#### `textSearch(string $textQuery, array $fields = ['*'], array $params = [])`\n- **$textQuery**: Search string (e.g., `\"restaurant\"`).\n- **$fields**: Fields to return. Default is all fields. [More info](https://developers.google.com/maps/documentation/places/web-service/choose-fields).\n- **$params**: Optional parameters. [More info](https://developers.google.com/maps/documentation/places/web-service/text-search).\n\n### Place Photo\n#### `placePhoto(string $name, int $maxHeightPx = null, int $maxWidthPx = null)`\n- **$name**: A string identifier that uniquely identifies a photo. [More Info](https://developers.google.com/maps/documentation/places/web-service/place-photos#photo-name)\n- **$maxHeightPx**: The maximum desired height of the image in pixels. (Should be between 1 and 4800)\n- **$maxWidthPx**: The maximum desired width of the image in pixels. (Should be between 1 and 4800)\n\u003e [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\n\n---\n\n\u003ca name=custom-headers\u003e\u003c/a\u003e\n# Custom Headers\n#### Set Custom Headers\n```php\nGooglePlaces::make()-\u003eheaders()-\u003eadd('Header-Key', 'Header-Value');\n```\n\n---\n\n\u003ca name=additional-methods\u003e\u003c/a\u003e\n# Additional Methods\n\n- **`setKey(string $key)`**: Set the API key.\n- **`getKey(string $key)`**: Get the API key being used.\n- **`verifySSL(bool $verifySSL = true)`**: Enable/disable SSL verification.\n- **`throwOnErrors(bool $throwOnError)`**:\n    - By default, no exception is thrown for API errors. You can check the request status with `$response-\u003estatus()`.\n    - When `throwOnError` is set to `true`, the library will throw exceptions on API failures.\n\n---\n\n# Contribution\n- Report issues or contribute to the `develop` branch.\n- Open issues/PRs to improve this documentation.\n\n---\n\n# License\nThis package is licensed under the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSachinAgarwal1337%2Fgoogle-places-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSachinAgarwal1337%2Fgoogle-places-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSachinAgarwal1337%2Fgoogle-places-api/lists"}