PHP code example of geocoder-php / algolia-places-provider

1. Go to this page and download the library: Download geocoder-php/algolia-places-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

geocoder-php / algolia-places-provider example snippets



use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;

$httpClient = new \Http\Discovery\Psr18Client();

// Unauthenticated
$provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient);
// Authenticated
$provider = new \Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces($httpClient, '<your-key>', '<your-app-id>');

$geocoder = new \Geocoder\StatefulGeocoder($provider, 'en');

$result = $geocoder->geocodeQuery(GeocodeQuery::create('Paris')->withLocale('fr-FR'));