shiishiji/google-places-sdk

There is no license information available for the latest version (1.1.2) of this package.

1.1.2 2022-08-17 19:45 UTC

This package is auto-updated.

Last update: 2024-10-18 00:28:18 UTC


README

Official google API documentation -> here

Installation

composer require shiishiji/google-places-sdk

Usage

  1. Get your access token and create Configuration object
use Shiishiji\GooglePlacesSDK\Config\Configuration;

$configuration = new Configuration(
    authToken: 'this-is-place-for-your-token', 
);
  1. Instantiate facade class
use Shiishiji\GooglePlacesSDK\GooglePlacesFacade;
use Shiishiji\GooglePlacesSDK\Client\JsonClientFactory;
use Shiishiji\GooglePlacesSDK\Transformer\TransformerContext;
use Shiishiji\GooglePlacesSDK\Transformer\NearbySearchFiltersTransformer;

$facade = new GooglePlacesFacade(
    configuration: $configuration,
)
  1. Examples

Execute Nearby Search request

use Shiishiji\GooglePlacesSDK\DTO\Input\NearbySearchFilters;
use Shiishiji\GooglePlacesSDK\DTO\Location;

$facade->getNearbyPlaces(new NearbySearchFilters(
    location: new Location(lat: '40', lng: '-110'),
    language: 'en',
    radius: 4000, 
));

Execute Find Place From Text request

use Shiishiji\GooglePlacesSDK\DTO\Input\FindPlaceByTextFilters;
use Shiishiji\GooglePlacesSDK\DTO\Input\Partials\Fields;

$facade->getPlacesFromText(new FindPlaceByTextFilters(
    input: 'Museum of Contemporary Art Australia',
    inputType: 'textquery',
    fields: new Fields([Fields::FORMATTED_ADDRESS, Fields::PLACE_ID]),
    locationBias: 'ipbias',
    language: 'en',
));

Development

Before any of command below, docker image must be build

docker build -t google-places-sdk . 

Install dependencies

docker run --rm -t -v $PWD:/app google-places-sdk composer install

Run tests

docker run --rm -t -v $PWD:/app google-places-sdk vendor/bin/phpspec run

Run PHP CS fixer

docker run --rm -t -v $PWD:/app google-places-sdk vendor/bin/php-cs-fixer fix