pixxet/laravel-geoip-world-cities
Composer 安装命令:
composer require pixxet/laravel-geoip-world-cities
包简介
Laravel GeoIP World Cities provides MaxMind Free World Cities Database for laravel applications.
关键字:
README 文档
README
Laravel GeoIP World Cities is package that provides MaxMind Free World Cities Database support for laravel applications.
Contents
- Introduction
- Before installing
- Installation
- Table structure
- Example
- Troubleshooting
- Changelog
- Contributing
- Credits
- License
Introduction
Includes city, region, country, latitude and longitude. This database doesn't contain any IP addresses. It's simply a listing of all the cities in the world.
This package simply loads the data provided in worldcitiespop.txt.gz file by MaxMind into a database and provides a City model to query the table.
Before installing
If you are looking for the Laravel 4 version, take a look Branch 1.0.
Installation
Note: This package is a bit large, ~40MB, installing and seeding the data could take a while.
Add pixxet/laravel-geoip-world-cities to composer.json:
"pixxet/laravel-geoip-world-cities": "2.*"
for the last stable version, or
"pixxet/laravel-geoip-world-cities": "dev-master"
for the latest version.
Run composer update to pull down laravel-geoip-world-cities.
Edit config/app.php and add the provider
'providers' => [ Pixxet\LaravelGeoIPWorldCities\LaravelGeoIPWorldCitiesServiceProvider::class, ]
Optionally add the alias.
'aliases' => [ 'Cities' => Pixxet\LaravelGeoIPWorldCities\Facade::class, ]
Configure MySQL and PDO, insert the following code in config/database.php:
'mysql' => [ 'options' => [PDO::MYSQL_ATTR_LOCAL_INFILE => true], ],
Publishing the configuration file, this is where you can change the default table name
php artisan vendor:publish
Publishing the migration and seeder files
php artisan cities:migration
php artisan cities:seeder
To make sure the data is seeded insert the following code in seeds/DatabaseSeeder.php
// Seeding the cities $this->call(CitiesTableSeeder::class); $this->command->info('Seeded the cities table ...');
You may now run:
php artisan migrate --seed
After running this command the filled cities table will be available
Table structure
| id | country | city | city_ascii | region | population | latitude | longitude |
|---|---|---|---|---|---|---|---|
| .. | .. | .. | .. | .. | .. | .. | .. |
| 2685662 | sd | Khartoum | khartoum | 29 | 1974780 | 15.588056 | 32.534167 |
| .. | .. | .. | .. | .. | .. | .. | .. |
Example
The package provides a City model which can be used to query the data
\Pixxet\LaravelGeoIPWorldCities\City::whereCity('Khartoum')->first();
Troubleshooting
If you are getting a ReflectionException when trying to seed
[ReflectionException]
Class CitiesTableSeeder does not exist
run:
composer dump-autoload
and try again.
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
MaxMind WorldCities License.
The MIT License (MIT). Please see License File for more information.
pixxet/laravel-geoip-world-cities 适用场景与选型建议
pixxet/laravel-geoip-world-cities 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 145 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 03 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「maxmind」 「geoip」 「laravel」 「laravel-geoip-world-cities」 「worldcitiespop」 「world-cities」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pixxet/laravel-geoip-world-cities 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pixxet/laravel-geoip-world-cities 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pixxet/laravel-geoip-world-cities 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A GeoIP decorator/processor for monolog
Ipgeobase PHP API
Geolocate IP addresses using a variety of third-party services
GeoIP package for Laravel 5.
PHP GeoIP client
统计信息
- 总下载量: 145
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-11