tigrov/yii2-country 问题修复 & 功能扩展

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

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

tigrov/yii2-country

Composer 安装命令:

composer require tigrov/yii2-country

包简介

Country data for Yii2 using Intl extension and more.

README 文档

README

The library provides access to Intl extension data for information about regions, sub-regions, countries, languages, locales, currencies and timezones. Also it has additional classes for information about continents, divisions, cities and measurement systems.

Latest Stable Version Build Status

The main classes:

  • Continent
  • Region
  • Subregion
  • Country (ActiveRecord)
  • Division (ActiveRecord)
  • City (ActiveRecord)
  • Locale
  • Language
  • Currency
  • Timezone
  • MeasurementSystem

Limitation

Since 1.1.0 requires Yii >= 2.0.13 and PHP >= 5.5

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist tigrov/yii2-country

or add

"tigrov/yii2-country": "~1.0"

to the require section of your composer.json file.

Configuration

Once the extension is installed, configure migrations in config.php:

return [
    // ...
    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrationController',
        ],
    ],
    // ...
];

and apply migrations:

yii migrate

Usage

The classes have access to static methods of Tigrov/intldata:

// Get list of codes.
ClassName::codes();

// Get a boolean indicating whether data has a code.
ClassName::has($code);

// Get list of names.
ClassName::names();

// Get name by code.
ClassName::name($code);

// E.g.
Country::names();
Currency::name('USD');
Locale::codes();
Timezone::has('America/New_York');

And some of the classes have additional static methods to get more information.

Also each of the classes has follow methods and attributes (perhaps magic):

// Create a model by code
ClassName::create($code);

// All models of a class
ClassName::all();

// Code of the model
$model->code;

// Name of the model
$model->name;

For example:

$continents = Continent::all();
$europe = Continent::create('EU');
$europe->code; // 'EU'
$europe->name; // 'Europe'

// List of countries
$europe->countries;

$us = Country::create('US');
$us->code; // 'US'
$us->name; // 'United States' (depends of the current locale)

// List of divisions (states)
$us->divisions;

// List of cities
$us->cities;

Addition

License

MIT

统计信息

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

GitHub 信息

  • Stars: 15
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固