mrssoft/yii2-globalstate

Save and load global data

Installs: 3 297

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 2

Open Issues: 1

Type:yii2-extension

dev-master 2022-12-11 08:05 UTC

This package is auto-updated.

Last update: 2024-11-11 12:11:06 UTC


README

Save and load global data

Install

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist mrssoft/yii2-globalstate "dev-master"

or add

"mrssoft/yii2-globalstate": "dev-master"

to the require section of your composer.json

Usage

Add to you config:

'components' => [
	'globalstate' => [
		'class' => 'mrssoft\globalstate\GlobalStateFile',
        'path' => '@runtime', // Path for save data (optional)
        'filename' => 'globalstate.bin' //Filename (optional)
	], 
]    

Get value:

$value = Yii::$app->globalstate->get('key');

//or

$value = Yii::$app->globalstate->get('key', $default);

Set value:

Yii::$app->globalstate->set('key', $value);