softedge/yii2-countries

Model and migration to add countries to your yii2 app

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.1.0 2019-10-22 16:13 UTC

This package is auto-updated.

Last update: 2024-04-23 02:11:04 UTC


README

  1. Introduction

Yii2 Countries --- Multilingual extension for the Yii2 framework, which provides a list of all countries and their demonym, plus a migration file and an AR model.

  • Requires agroxy/yii2-multilingual (Github)
  • Multilanguage support
  1. Dependencies
  • php >= 7.0
  • composer
  • MySql >= 5.5
  • agroxy/yii2-multilingual
  1. Installation

Via composer:

composer require "softedge/yii2-countries": "^1.1.0"

or add the following in section require of composer.json:

"require": {
    "softedge/yii2-countries": "^1.1.0"
}

and run command composer install,

or command composer update, if all yii2 project extensions are already installed.

  1. Usage

Main properties

The namespace for classes: slayvin\countries.

Application config

To add the tables to the database, run the provided migration:

'controllerMap' => [
        'migrate' => [
            'class' => yii\console\controllers\MigrateController::class,
            'migrationNamespaces' => [
                'slayvin\countries\migrations'
            ],
        ]
    ],

If you need multilingual support, add the languages in your app config params:

...
'languages' => ['en',...]
...

Database tables

Country table "countries"

iso selectable default
AD 0 0
AE 0 0
... ... ...
ZW 0 0

Translation table "countries_lang"

country_iso language name demonym
AD en Andorra Andorran
AE en United Arab Emirates Emirati
... ... ... ...
ZW fr Zimbabwe Zimbabwéen-ne

Here, we have:

  • non-multilingual fields: iso, selectable, default
  • multilingual fields: name, demonym

License

Licensed under the MIT license.