Package Data | |
---|---|
Maintainer Username: | Ruslan A. |
Maintainer Contact: | ruslan.a94@yandex.com (Ruslan A.) |
Package Create Date: | 2017-02-01 |
Package Last Update: | 2024-02-10 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:00:03 |
Package Statistics | |
---|---|
Total Downloads: | 114,173 |
Monthly Downloads: | 3,271 |
Daily Downloads: | 41 |
Total Stars: | 14 |
Total Watchers: | 3 |
Total Forks: | 6 |
Total Open Issues: | 1 |
A PHP package for working with the SypexGeo database file.
The current version supports Laravel 5.5 and later. If you need support Laravel 5.4 or older, see version 1.*.
1. Add the package through composer:
composer require eseath/sypexgeo
2. Publish config sxgeo.php
(optionally):
php artisan vendor:publish --provider="Eseath\SxGeo\SxGeoServiceProvider"
By default in config specified URL to the database of cities. If you want the database of countries, change url:
...
'dbFileURL' => 'https://sypexgeo.net/files/SxGeoCountry.zip',
...
3. Download the database file:
php artisan sxgeo:update
You can use this command to upgrade database to the current version via CRON.
Also you can download the database manually:
use Eseath\SxGeo\SxGeo;
$sxGeo = new SxGeo('/path/to/database/file.dat');
$fullInfo = $sxGeo->getCityFull($ip)
$briefInfo = $sxGeo->get($ip);
use SxGeo;
$data = SxGeo::getCityFull($ip);
array:3 [▼
"city" => array:5 [▼
"id" => 524901
"lat" => 55.75222
"lon" => 37.61556
"name_ru" => "Москва"
"name_en" => "Moscow"
]
"region" => array:4 [▼
"id" => 524894
"name_ru" => "Москва"
"name_en" => "Moskva"
"iso" => "RU-MOW"
]
"country" => array:6 [▼
"id" => 185
"iso" => "RU"
"lat" => 60
"lon" => 100
"name_ru" => "Россия"
"name_en" => "Russia"
]
]
array:2 [▼
"city" => array:5 [▼
"id" => 524901
"lat" => 55.75222
"lon" => 37.61556
"name_ru" => "Москва"
"name_en" => "Moscow"
]
"country" => array:2 [▼
"id" => 185
"iso" => "RU"
]
]