承接 smart/geo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

smart/geo

最新稳定版本:0.4.0

Composer 安装命令:

composer require smart/geo

包简介

Smart Geo is databases from Open Data providers compiled into easy to use PHP objects.

README 文档

README

Smart Geo

Build Status Latest Stable Version Total Downloads License

Smart Geo is databases from Open Data providers compiled into easy to use PHP objects.

  1. Features
  2. Sources
  3. Requirements
  4. Installation
  5. Country
  6. Region

Features

  • Multiple languages (Currently only supports English, French and German).
  • Country Database
  • Region Database (Currently only for Canada and the United States).
  • IP Geolocation (With MaxMind)

Sources

Requirements

Smart Geo does not require a database, but instead, uses JSON files.

This library uses PHP 5.6+.

Installation

You need to install the Smart Geo library through composer. To do so, add the following lines to your composer.json file.

{
    "require": {
       "smart/geo": "dev-master"
    }
}

To download or update the current data, use the following command.

php vendor/bin/geo data:update

Country

Database of all countries in the world.

Properties

  • Names
  • Short Code (Alpha-2 code)
  • Code (Alpha-3 code)
  • Latitude
  • Longitude
  • Bounding Box
  • Currency
  • Continent
  • Population
  • Area
  • Capital
  • Timezone

Examples

Get a list of all countries.

$countryCollection = (new Geo)->getCountryRepository()->findAll();

Get country name in english.

foreach ($countryCollection as $country) {
   echo $country->getNames()->get('en');
}

Order by country name in english.

$countryCollection->orderByName();

Region

Database of all States, Federal Districts and Territories in the United States, Provinces and Territories in Canada.

Properties

  • Name
  • Code (Alpha-2 code)
  • Country
  • Type
  • Latitude
  • Longitude
  • Bounding Box

Examples

Get a list of all regions in the US.

$geo = new Geo;
$country = $geo->getCountryRepository()->findByCode('US');
$regionCollection = (new Geo)->getRegionRepository()->findByCountry($country);

Get region name and type in english.

foreach ($regionCollection as $region) {
   echo $region->getNames()->get('en') . " is a " . 
       $region->getType()::class . " of the " . 
       $country->getNames()->get('en);
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-24