https://github.com/agoalofalife/geography
Building a hierarchy of regions
https://github.com/agoalofalife/geography
cities country geography php-geography regions
Last synced: 7 months ago
JSON representation
Building a hierarchy of regions
- Host: GitHub
- URL: https://github.com/agoalofalife/geography
- Owner: agoalofalife
- Created: 2017-04-10T14:07:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-02-05T11:45:33.000Z (over 4 years ago)
- Last Synced: 2025-03-27T08:03:33.467Z (7 months ago)
- Topics: cities, country, geography, php-geography, regions
- Language: PHP
- Homepage:
- Size: 70.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[EN](https://github.com/agoalofalife/geography/blob/master/README.md) | [RU](https://github.com/agoalofalife/geography/blob/master/README_RU.md)
**The geography of the regions**
[](https://travis-ci.org/agoalofalife/geography) [](https://packagist.org/packages/agoalofalife/geography) [](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D) [](https://scrutinizer-ci.com/g/agoalofalife/geography/?branch=master) [](https://scrutinizer-ci.com/g/agoalofalife/geography/build-status/master)
**What is it?**
This package solves the problem with the hierarchy of countries, regions, settlements in your database.
A few commands in the console, you deploy all the necessary the country , regardless of country and language.
**The installation of the package**
For installation, you must run the command from composer
composer require agoalofalife/geography
**Data migration**
Run the command :
```
vendor/bin/geography install
```
Following the instructions step by step, continue to enter information.
1. Database selection
```
======================================
Please choose your database type :
[ 0 ] mysql
[ 1 ] postgres
```
2. Choice your host
```
Enter host for database , please : localhost
```
2. The name of the database:
```
Enter database name, please : test
```
3. The user in the database:
```
Enter database username, please : root
```
4. The password in the database (not shown):
```
Enter database password, please :
```
5. To select the language:
```
Please select your native language :
[0] ru
[1] en
[2] ua
[3] be
[4] es
[5] fi
[6] de
[7] it
>
```
5. Choose the country you want to migrate, for example I need a few countries (Australia and Brazil), respectively, I would need to enter : **AU,BR**
```
the list of countries you can see here 3166-1 alpha-2
you can specify multiple countries separated by commas
example EN, RU
Enter the country you wish to migrate, please :
```
After some time, depending on the volume of information you will see in my database three tables :
- Country
- Regions
- Сities
```
You have just selected: AU,BR
3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
```
Congratulations to all successful!
**Integration with Laravel**
Since the environment Laravel uses for its tables Seeder and Migration, we can freely copy it to your project Laravel!
```
vendor/bin/geography migrate:laravel
```
After you get your files in a folder database and config.
To configure your language and countries you want to migrate, you must change the configuration file in config/geography.php :
```
return [
// Your native language
// 0 — Russian,
// 1 — Ukrainian,
// 2 — Belarusian,
// 3 — English,
// 4 — Spanish,
// 5 — Finnish,
// 6 — German,
// 7 — Italian.
'locale' => 0,
// Country you wish to migrate
// standard 3166-1 alpha-2
// example RU,AU
'country' => 'RU',
'nameTable' => [
'country' => 'country',
'regions' => 'regions',
'cities' => 'cities'
],
'access_token' => ''
];
```
Next, you need to perform :
```
composer dump
php artisan migrate
php artisan db:seed
или для seeder :
php artisan db:seed --class=CountryTableSeeder
php artisan db:seed --class=RegionsTableSeeder
php artisan db:seed --class=CitiesTableSeeder
```
After you can easily remove the package and what not to worry!
[