diggindata/yii2-geonames 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

diggindata/yii2-geonames

Composer 安装命令:

composer require diggindata/yii2-geonames

包简介

Yii2 GeoNames Module. Manage downloading and importing GeoNames data. CRUD UI for tables.

README 文档

README

This extension provides a GeoNames management solution for Yii framework 2.0, containing import scripts and a CRUD UI.

It is an adaption of the Laravel / Lumen / Eloquent Geonames scripts at https://github.com/yurtesen/geonames

For license information check the LICENSE-file.

Latest Stable Version

1. Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist diggindata/yii2-geonames:dev-master

or

php composer.phar require --prefer-dist diggindata/yii2-geonames

or add

"diggindata/yii2-geonames": "@dev"

to the require section of your composer.json, then run

composer install

2. Configuration

Folders

We need a folder to store downloaded data files from geonames.org. So in your application's base directory, create the directories data and data/geonames. This directory will hold the downloaded data files from geonames.org.

Application Configuration

Add following lines to both, your web and your console configuration file to enable this module (config/web.php and config/console.php):

    ...
    'modules' => [
        ...
        'geonames' => [
            'class' => 'diggindata\geonames\Module',
        ],
    ],

Commandline Configuration

The yii geonames shell command can be configured.

Create a file geonames.php in the config directory of your Yii application.

You may use the file vendoe/diggindata/yii2-geonames/geonames.php.example file as a template.

All available configuration options are listed below with their default values.

proxy (type: string, default: null)

  • URL with port of proxy server

proxy_user (type: string, default: null)

  • Proxy usernanme

proxy_pass (type: string, default: null)

  • Proxy user password

keepTxt (type: boolean, default: true)

storagePath (default: Yii::getAlias('@app/data') . '/geonames')

ignoreTables

Array of tables which would be ignored in imports. Some tables might note be used by you, e.g. alternate_names table.
Uncommenting it will stop auto-import.

countries (type: array, default: array())

Array of 2-Char ISO codes of countries which shall be imported. If the array is empty, the allCountries file is imported.

3. Update Database Schema

Finally you need to update your database schema by applying the provided migrations. Make sure that you have properly configured your db application component, then run the following command:

$ php yii migrate/up --migrationPath=@vendor/diggindata/yii2-geonames/src/migrations

Where do I go now?

By now you should have Yii2-geonames installed. You may now open the geonames module. You should also be able to import geonames data via the console commqand, see Usagebelow.

Usage

Download Data

Enter the following command within your application's folder:

yii geonames/geonames/download

This will download data files:

[] zip
+--- DE.zip
iso-languagecodes.txt
timeZones.txt
admin1CodesASCII.txt
admin2Codes.txt
countryInfo.txt
DE.zip
featureCodes_en.txt
hierarchy.zip

To update already existing files, add the -u flag.

Import Data

Enter the following command within your application's folder:

yii geonames/geonames/seed

This will insert the downloaded data into the respective database tables.

Tipps

Delete duplicate postal codes

-- Add Auto-Increment PK
ALTER TABLE `postalcode`
ADD `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY;

-- Delete duplicates
DELETE t1 FROM postalcode t1
INNER JOIN postalcode t2 
WHERE 
    t1.id > t2.id AND (
    t1.countryCode = t2.countryCode AND
    t1.postalCode = t2.postalCode AND
    t1.placeName = t2.placeName AND
    t1.admin1Code = t2.Admin1Code AND
    t1.admin2Code = t2.admin2Code AND
    t1.admin3Code = t2.admin3Code AND
    t1.latitude = t2.latitude AND
    t1.longitude = t2.longitude
);

-- Drop Auto-Increment PK
ALTER TABLE postalcode DROP `id`;

diggindata/yii2-geonames 适用场景与选型建议

diggindata/yii2-geonames 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 329 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「module」 「yii2」 「geonames」 「yii2-geonames」 「diggin-data」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 diggindata/yii2-geonames 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 diggindata/yii2-geonames 我们能提供哪些服务?
定制开发 / 二次开发

基于 diggindata/yii2-geonames 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 329
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-11-01