2017 © Pedro Peláez
 

yii2-extension yii2-country

Country data for Yii2 using Intl extension and more.

image

tigrov/yii2-country

Country data for Yii2 using Intl extension and more.

  • Thursday, March 1, 2018
  • by Tigros
  • Repository
  • 1 Watchers
  • 2 Stars
  • 134 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 7 % Grown

The README.md

Country data for Yii2

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., (*1)

Latest Stable Version Build Status, (*2)

The main classes: - Continent - Region - Subregion - Country (ActiveRecord) - Division (ActiveRecord) - City (ActiveRecord) - Locale - Language - Currency - Timezone - MeasurementSystem, (*3)

Limitation

Since 1.1.0 requires Yii >= 2.0.13 and PHP >= 5.5, (*4)

Installation

The preferred way to install this extension is through composer., (*5)

Either run, (*6)

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

or add, (*7)

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

to the require section of your composer.json file., (*8)

Configuration

Once the extension is installed, configure migrations in config.php:, (*9)

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

and apply migrations:, (*10)

yii migrate

Usage

The classes have access to static methods of Tigrov/intldata:, (*11)

// 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., (*12)

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

// 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:, (*14)

$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

  • For additional information about countries (flags, codes, borders and other) use a library
    https://github.com/rinvex/countries $country->rinvex
    or https://github.com/antonioribeiro/countries
  • For more information about Intl extension data see
    https://github.com/Tigrov/intldata
    http://intl.rmcreative.ru/tables?locale=en_US
    http://php.net/manual/book.intl.php

License

MIT, (*15)

The Versions

01/03 2018

dev-master

9999999-dev

Country data for Yii2 using Intl extension and more.

  Sources   Download

MIT

The Requires

 

by Sergei Tigrov

language yii2 locale i18n internationalization localization currency timezone country continent intl l10n measurement region time zone

01/03 2018

1.1.0

1.1.0.0

Country data for Yii2 using Intl extension and more.

  Sources   Download

MIT

The Requires

 

by Sergei Tigrov

language yii2 locale i18n internationalization localization currency timezone country continent intl l10n measurement region time zone

07/01 2018

1.0.1

1.0.1.0

Country data for Yii2 using Intl extension and more.

  Sources   Download

MIT

The Requires

 

by Sergei Tigrov

language yii2 locale i18n internationalization localization currency timezone country continent intl l10n measurement region time zone

25/12 2017

1.0.0

1.0.0.0

Country data for Yii2 using Intl extension and more.

  Sources   Download

MIT

The Requires

 

by Sergei Tigrov

language yii2 locale i18n internationalization localization currency timezone country continent intl l10n measurement region time zone