Skip to content

DenisProgrammer/sypexgeo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SypexGeo PHP API

Minimum PHP Version Latest stable version Build Status

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.*.

Installation for Laravel >=5.5

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:

Usage

use Eseath\SxGeo\SxGeo;

$sxGeo = new SxGeo('/path/to/database/file.dat');
$fullInfo  = $sxGeo->getCityFull($ip);
$briefInfo = $sxGeo->get($ip);

With Laravel

use SxGeo;

$data = SxGeo::getCityFull($ip);

Example Data

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"
    ]
]

About

Unofficial PHP package for working with the IPs database file by SypexGeo. Supports Laravel 5.5 and later.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%