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
Requires
- php: >=7.0.0
- yiisoft/yii2: ~2.0.14
Suggests
- agroxy/yii2-multilingual: Allows multilingual attributes for AR models
This package is auto-updated.
Last update: 2025-02-23 03:53:23 UTC
README
- 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
- Dependencies
- php >= 7.0
- composer
- MySql >= 5.5
- agroxy/yii2-multilingual
- 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.
- 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.