2amigos / google-places-library
Google Places API Library
Installs: 70 939
Dependents: 1
Suggesters: 0
Security: 0
Stars: 9
Watchers: 18
Forks: 2
Open Issues: 0
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.3
- phpmd/phpmd: @stable
- phpunit/phpunit: 5.*
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2023-08-09 19:59:13 UTC
README
Extension library to interact with Google Places API
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require 2amigos/google-places-library
or add
"2amigos/google-places-library": "*"
to the require
section of your composer.json
file.
Usage
Using SearchClient
class:
use Da\Google\Places\Client\SearchClient
$search = new SearchClient('{YOURGOOGLEAPIKEY}');
// $search->forceJsonArrayResponse(); // if you want to get arrays instead of objects
// $search = new SearchClient('{YOURGOOGLEAPIKEY}', 'xml'); // if you wish to handle XML responses (JSON is highly recommended)
// If you setup the format in 'xml', the returned value will be an array.
// The library will decode the response automatically
var_dump($search->text('restaurants in Inca Mallorca'));
Using PlaceClient
class:
use Da\Google\Places\Client\PlaceClient
$place = new PlaceClient('{YOURGOOGLEAPIKEY}');
// $place = new PlaceClient('{YOURGOOGLEAPIKEY}', 'xml'); // if you wish to handle XML responses (JSON is highly recommended)
$place->details('{REFERENCEIDOFPLACE}'));
Further Information
For further information regarding the multiple parameters of Google Places please visit its API reference
Contributing
Please see CONTRIBUTING for details.
Clean code
We have added some development tools for you to contribute to the library with clean code:
- PHP mess detector: Takes a given PHP source code base and look for several potential problems within that source.
- PHP code sniffer: Tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
- PHP code fixer: Analyzes some PHP source code and tries to fix coding standards issues.
And you should use them in that order.
Using php mess detector
Sample with all options available:
./vendor/bin/phpmd ./src text codesize,unusedcode,naming,design,controversial,cleancode
Using code sniffer
./vendor/bin/phpcs -s --report=source --standard=PSR2 ./src
Using code fixer
We have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules.
./vendor/bin/php-cs-fixer fix ./src
Testing
$ ./vendor/bin/phpunit
Credits
License
The BSD License (BSD). Please see License File for more information.
Custom Software Development | Web & Mobile Development Software
www.2amigos.us