gplacesphp / api-client
Modern Google Places API client for PHP
Installs: 2 256
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: ^7.1
- ext-json: *
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- ext-mbstring: *
- bamarni/composer-bin-plugin: ^1.2
- phpunit/phpunit: ^7.4
- symfony/phpunit-bridge: ^4.1
- symfony/var-dumper: ^4.1
This package is auto-updated.
Last update: 2024-10-23 17:05:20 UTC
README
Build status
Introduction
Modern, Object-Oriented, client for using Google's Places API, requires PHP v7.1+. Any PSR-7 (HTTP Message Interface) and PSR-17 (HTTP Factories) implementations is supported (and required). Supports caching by any PSR-16 (simple cache) implementation, also works with any HTTPlug client/adapter.
Installation
composer require gplacesphp/api-client
Usage
This examples uses php-http/guzzle6-adapter
as a PSR-18 implementation
and zendframework/zend-diactoros
as a PSR-7/PSR-17 implementation.
Any other PSR-7/PSR-17/PSR-18 implementations are supported.
If you don't have them installed you will need to run:
composer require \ guzzlehttp/guzzle \ php-http/guzzle6-adapter \ zendframework/zend-diactoros
Remember to replace <YOUR_API_KEY>
with you key.
More usage examples are in examples
directory.
Place details
Basic example
<?php require_once __DIR__ . '/vendor/autoload.php'; $apiKey = '<YOUR_API_KEY>'; $guzzle = new \GuzzleHttp\Client(); $httpClient = new \Http\Adapter\Guzzle6\Client($guzzle); $requestFactory = new \Zend\Diactoros\RequestFactory(); $client = \GPlacesPhp\ApiClient\Client::create( $apiKey, $httpClient, $requestFactory ); $placeDetails = $client->placeDetails('ChIJAZ-GmmbMHkcR_NPqiCq-8HI'); // Warsaw var_dump($placeDetails);
Find place
Basic example
<?php require_once __DIR__ . '/vendor/autoload.php'; $apiKey = '<YOUR_API_KEY>'; $guzzle = new \GuzzleHttp\Client(); $httpClient = new \Http\Adapter\Guzzle6\Client($guzzle); $requestFactory = new \Zend\Diactoros\RequestFactory(); $client = \GPlacesPhp\ApiClient\Client::create( $apiKey, $httpClient, $requestFactory ); $findPlace = $client->findPlace('Warszawa, Polska'); // Warsaw var_dump($findPlace);
TODOs
Things to do before stable v1
release:
- Place Details
- Caching Place Details
- Places Search
- Find Place
- Nearby Search
- Text Search
- Caching Places Search
- Find Place
- Nearby Search
- Text Search
- Place Photos
- Caching Place Photos
- Use
PSR-18
instead ofHTTPlug
License
This package is free software distributed under the terms of the MIT license.