PHP code example of velhron / dadata-bundle

1. Go to this page and download the library: Download velhron/dadata-bundle 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/ */

    

velhron / dadata-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Velhron\DadataBundle\VelhronDadataBundle(),
        );

        // ...
    }

    // ...
}



// ...

use Velhron\DadataBundle\Service\DadataSuggest;

class BaseController extends AbstractController
{
    private $dadataSuggest;

    public function __construct(DadataSuggest $dadataSuggest)
    {
        $this->dadataSuggest = $dadataSuggest;
    }
}

$response = $dadataSuggest->suggestAddress('москва хабар', ['count' => 10]);
$address = $response[0]->value;

$response = $dadataSuggest->suggestParty('сбербанк', ['count' => 2]);
$inn = $response[0]->inn;

$response = $dadataClean->cleanName('Срегей владимерович иванов');
$name = $response->result;

$response = $dadataGeolocate->geolocateAddress(55.878, 37.653);
$address = $response[0]->value;

$response = $dadataIplocate->iplocateAddress('46.226.227.20');
$city = $response->value;

$response = $dadataSuggest->findAddress('77000000000268400');
$address = $response[0]->value;

$response = $dadataSuggest->findAffiliatedParty('7736207543');
$value = $response[0]->value;