定制 eseath/sypexgeo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eseath/sypexgeo

最新稳定版本:v2.3.2

Composer 安装命令:

composer require eseath/sypexgeo

包简介

A PHP package for working with the SypexGeo database file.

README 文档

README

Minimum PHP Version Latest stable version Build Status

A PHP package for working with the SypexGeo database file.

The current version supports Laravel 5.1 and later.

Installation

composer require eseath/sypexgeo

For non-Laravel projects, you need to manually download the database file:

The database is updated 2 times a month.

Setup

Laravel

1. If Laravel version <= 5.4, add into config/app.php:

    'providers' => [
        \Eseath\SxGeo\SxGeoServiceProvider::class,
    ]

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.

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

Running Tests

The tests are run automatically by Travis CI on multiple PHP and Laravel versions.

If you want to run tests locally, use the following command:

python3 ./test.py

Development

docker-compose run php-7.1 composer install

统计信息

  • 总下载量: 166.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-01