PHPackages                             yiimaker/yii2-data-static - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yiimaker/yii2-data-static

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

yiimaker/yii2-data-static
=========================

Yii2 Static Data

1.2.2(9y ago)323BSD-3-ClausePHP

Since Jan 3Pushed 9y ago2 watchersCompare

[ Source](https://github.com/yiimaker/yii2-data-static)[ Packagist](https://packagist.org/packages/yiimaker/yii2-data-static)[ RSS](/packages/yiimaker-yii2-data-static/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (12)Used By (0)

Yii2 Static Data
================

[](#yii2-static-data)

It is a model for the data that stores configuration. `StaticData` subject to the same rules as `yii\base\Model`

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yiimaker/yii2-data-static "*"
```

or add

```
"yiimaker/yii2-data-static": "*"
```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

1. Configure component `yiimaker/yii2-configuration` in config file or in `StaticData` class. [More information](https://github.com/yiimaker/yii2-configuration#configuration)
2. Inherit the class `ymaker\data\statics\StaticData`, then describe it as a normal model.

Example
-------

[](#example)

StaticData
----------

[](#staticdata)

```
class AboutUs extends ymaker\data\statics\StaticData
{
    public $phone;
    public $email;

    public function rules()
    {
        return [
            [['phone', 'email'], 'required'],
            ['phone', 'string', 'max' => 255],
            ['email', 'email']
        ];
    }
}
```

```
$aboutUs = new AboutUs();
```

#### Save Data

[](#save-data)

```
$aboutUs->phone = '+111111111111';
$aboutUs->email = 'test@example.com';
$aboutUs->save();
```

#### Load Data

[](#load-data)

```
$aboutUs->loadAttributes();
echo $aboutUs->email; // 'test@example.com';
```

or

```
$aboutUs = AboutUs::getInstance();
```

#### Reload Data

[](#reload-data)

```
$aboutUs->loadAttributes();
$aboutUs->email = 'another@example.com';
$aboutUs->reload();

echo $aboutUs->email; // 'test@example.com';
```

StaticDataTranslation
---------------------

[](#staticdatatranslation)

```
class AboutUs extends ymaker\data\statics\StaticDataTranslation
{
    public $address;

    public function rules()
    {
        return [
            [['address'], 'required'],
            ['address', 'string', 'max' => 255],
        ];
    }
}
```

```
$aboutUs = new AboutUs(['language' => 'en-US']);
// $about
```

#### Save Data

[](#save-data-1)

```
$aboutUs->address = 'Kiev, Ukraine';
$aboutUs->save();
$aboutUs->setLanguage('ru-RU');
$aboutUs->address = 'Киев, Украина';
$aboutUs->save();
```

#### Load Data

[](#load-data-1)

```
$aboutUs->loadAttributes();
echo $aboutUs->address; // 'Киев, Украина'
$aboutUs->changeLanguage('en-US');
echo $aboutUs->address; // 'Kiev, Ukraine'
```

or

```
$aboutUs = AboutUs::getInstance(['language' => 'en-US']);
```

#### Reload Data

[](#reload-data-1)

```
$aboutUs->loadAttributes();
$aboutUs->address = 'Лондон, Великобритания';
$aboutUs->reload();

echo $aboutUs->address; // 'Киев, Украина'
```

#### change language

[](#change-language)

```
    /**
     * change language for model
     * @param $language string language code
     * @param bool $reload If true, then all attributes will be overwritten
     */
    public function changeLanguage($language, $reload = true);
```

```
echo $aboutUs->address; // 'Киев, Украина'
$aboutUs->changeLanguage('en-US');
echo $aboutUs->address; // 'Kiev, Ukraine'

$aboutUs->changeLanguage('ru-RU', false);
echo $aboutUs->address; // 'Kiev, Ukraine'

$aboutUs->reload();
echo $aboutUs->address; // 'Киев, Украина'
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

11

Last Release

3410d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81dbf9eb881773e58a5472007499612c6e0c93007a75336688a1a21b9630dc1e?d=identicon)[YiiMaker](/maintainers/YiiMaker)

---

Top Contributors

[![trabem](https://avatars.githubusercontent.com/u/3384909?v=4)](https://github.com/trabem "trabem (20 commits)")

---

Tags

modelstaticyii2-extensionyii2extensionstatic data

### Embed Badge

![Health badge](/badges/yiimaker-yii2-data-static/health.svg)

```
[![Health](https://phpackages.com/badges/yiimaker-yii2-data-static/health.svg)](https://phpackages.com/packages/yiimaker-yii2-data-static)
```

###  Alternatives

[vyants/yii2-daemon

Extension provides functionality for simple daemons creation and control

7859.0k](/packages/vyants-yii2-daemon)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
