PHP code example of gocanto / places-validation

1. Go to this page and download the library: Download gocanto/places-validation 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/ */

    

gocanto / places-validation example snippets


Gocanto\AddressValidation\ValidatorServiceProvider::class

'driver' => [

  //api key if ject
  'name' => 'GeoogleGeocode',

  //api url
  'api' => 'http://maps.google.com/maps/api/geocode/json'
],

$rules = [
  'address' => 'valid_place'
];

$data = [
  'address' => 'Guacara, Carabobo, Venezuela'
];

$v = \Validator::make($data, $rules);

use Gocanto\AddressValidation\Lib\Checker;

public function index(Checker $places)
{

  if ( ! $v = $places->validate('Guacara, Carabobo, Venezuela')) {
    //the place is not valid.
  }

  //retrieve the place information.
  dd($v->retrieve(), $v->location());
}
config/addressval.php