lysak/yii2-sypexgeo
Composer 安装命令:
composer require lysak/yii2-sypexgeo
包简介
Yii2 extension for Sypex Geo API (http://sypexgeo.net)
关键字:
README 文档
README
This extension adds support for Sypex Geo to the Yii2 framework
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist lysak/yii2-sypexgeo "*"
or add
"lysak/yii2-sypexgeo": "^1.0"
to the require section of your composer.json.
What it is all about?
Sypex Geo - product for location by IP address. Obtaining the IP address, Sypex Geo outputs information about the location of the visitor - country, region, city, geographical coordinates and other in Russian and in English. Sypex Geo use local compact binary database file and works very quickly. For more information visit: http://sypexgeo.net/
This is extension for Yii2 framework that makes it easy to deal with Sypex Geo.
Usage
Unfortunately, original version of Sypex Geo does not support Composer installation, so we have to include it into this extension.
First of all, you have to download desired database from the http://sypexgeo.net/ website and place it somewhere on your server.
There are two classes in this extension.
SypexGeo - this is the component can be used to retrieve Geo information based on IP address. Component encapsulates calls to the SxGeo methods.
You can use it as an application component:
// config.php [ 'components' => [ 'sypexGeo' => [ 'class' => 'lysak\components\SypexGeo', 'database' => '@app/data/SxGeoCity.dat', ] ] ] // somewhere in your code $city = Yii::$app->sypexGeo->getCity($ip);
Also, you can create an instance by yourself:
use lysak\components\SypexGeo; // ... $sypexGeo = new SypexGeo([ 'database' => '@app/data/SxGeoCity.dat', ]); $city = $sypexGeo->getCity($ip);
GeoBehavior - behavior that can be attached to the yii\web\Request or it's children and this class adds methods
to simplify getting Geo information for current request.
Example:
// config.php [ 'components' => [ 'request' => [ 'as sypexGeo' => [ 'class' => 'lysak\behaviors\GeoBehavior', // It is not required property if you have SypexGeo component defined in your application 'config' => [ 'database' => '@app/data/SxGeoCity.dat', ] ] ] ], ] // In your code $city = Yii::$app->request->getCity();
lysak/yii2-sypexgeo 适用场景与选型建议
lysak/yii2-sypexgeo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geo」 「module」 「extension」 「yii2」 「sypexgeo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lysak/yii2-sypexgeo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lysak/yii2-sypexgeo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lysak/yii2-sypexgeo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Show geo marker on a mapbox map
Show geo shape on a mapbox map with drawing capabilities
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2021-01-07