dimanzver / sxgeo
该软件包最新版本(1.0.3)没有提供许可证信息。
1.0.3
2024-05-27 09:18 UTC
Requires
- php: >5.3
README
用法
1. 在您的应用程序中设置数据库路径
$app['sypex_geo'] = []; $app['sypex_geo']['database'] = 'SxGeoCity.dat';
2. 在您的应用程序中注册「SypexGeoServiceProvider」
$app->register(new \Astartsky\SypexGeo\Silex\SypexGeoServiceProvider());
3. 用「SypexGeoTrait」扩展您的应用程序类
class AwesomeApplication extends \Silex\Application { ... use SypexGeoTrait; ... }
4. 享受您的新集成! :)
$city = $app->getSypexGeoAdapter()->getCity(**IP**) var_dump($city);
输出将如下所示
object(Astartsky\SypexGeo\Bean\City)[613] protected 'id' => int 524901 protected 'latitude' => float 55.75222 protected 'longitude' => float 37.61556 protected 'nameRu' => string 'Москва' (length=12) protected 'nameEn' => string 'Moscow' (length=6) protected 'region' => object(Astartsky\SypexGeo\Bean\Region)[612] protected 'id' => int 524894 protected 'iso' => string 'RU-MOW' (length=6) protected 'nameRu' => string 'Москва' (length=12) protected 'nameEn' => string 'Moskva' (length=6) protected 'country' => object(Astartsky\SypexGeo\Bean\Country)[611] protected 'id' => int 185 protected 'iso' => string 'RU' (length=2) protected 'latitude' => int 60 protected 'longitude' => int 100 protected 'nameRu' => string 'Россия' (length=12) protected 'nameEn' => string 'Russia' (length=6)
「composer install」命令更新
1. 在 composer.json 中添加「post-install-cmd」事件
"scripts": { "post-install-cmd": [ "Astartsky\\SypexGeo\\Composer::installDatabases" ] }
2. 在 composer.json 中添加「extra」设置
"extra": { "sypex_geo_update": "https://sypexgeo.net/files/SxGeoCity_utf8.zip", "sypex_geo_database": "SxGeoCity.dat" }