To use FIAS
Change the config app/config/database.php
to your database
To specify prefixes for deletion, you can change the config app/config/specifications.php
composer install
<?php
$geo = new \GeoFixer\GeoFixerFacade();
If you want to use the FIAS database, I recommend using this a repository to install the DB. After, you need to add the parameter:
<?php
$geo = new \GeoFixer\GeoFixerFacade($fias = true);
You can enable logs and set you own database config by:
<?php
$config = [
'host' => 'localhost',
'database' => 'fias',
'username' => 'root',
'password' => 'password'
];
$geo = new \GeoFixer\GeoFixerFacade($fias = true, $logs = true, $config);
<?php
/* array where you need to find a word */
$find_in = ['Москва', 'Екатеринбург', 'Томск'];
/* word received from the user */
$find_to = 'город Москва';
/* the most suitable word for the string $find_to returns from the $find_in array */
$result = $geo->findSimilarWord($find_to, $find_in);
/* if more rigorous selection is needed,
Then you need to add a third parameter */
$result = $geo->findSimilarWord($find_to, $find_in, $strict_search = true);
<?php
$region = 'Ленинрадская область';
/* will return the region id or false */
$code = $geo->findFiasRegion($region);
Additional parameters are possible:
<?php
/* the number of first letters in the region that must match */
$first_letters = 2;
$code = $geo->findFiasRegion($region, $first_letters, $strict_search = true);
<?php
$first_letters = false;
$strict_search = false;
$full_settlements = true; // search not only for cities, but also for settlements
$city = 'Благовещенск';
$region_code = 28;
$id = $geo->findFiasSettlement($city, $region_code, $first_letters, $strict_search, $full_settlements);
<?php
$first_letters = false;
$strict_search = false;
$street = 'Амурская';
$city_id = '8f41253d-6e3b-48a9-842a-25ba894bd093';
$id = $geo->findFiasStreet($street, $city_id, $first_letters, $strict_search);
<?php
$street_id = '3e0d1213-1212-4f87-bdd3-5f8ef6f6473e';
$house = 261;
$building = false; // if necessary, you can specify the body of building
$id = $geo->findFiasHouse($house, $street_id, $building);
<?php
$region = 'Ленинрадская область';
/* will return the region id or false */
$code = $geo->findKladrRegion($region);
<?php
$first_letters = false;
$strict_search = false;
$full_settlements = true; // search not only for cities, but also for settlements
$city = 'Благовещенск';
$region_code = 2800000000000;
$id = $geo->findKladrSettlement($city, $region_code, $first_letters, $strict_search, $full_settlements);
<?php
$first_letters = false;
$strict_search = false;
$street = 'Амурская';
$city_code = '2800000100000';
$id = $geo->findKladrStreet($street, $city_code, $first_letters, $strict_search);
vendor/bin/phpunit
vendor/bin/phpunit --group common
vendor/bin/phpunit --group fias