pozitronik/yii2-cachedwidget

Caching support for Yii2 widgets

Installs: 3 470

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.1.0 2020-07-28 07:17 UTC

This package is auto-updated.

Last update: 2024-10-29 05:53:18 UTC


README

Caching support for Yii2 widgets

Installation

The preferred way to install this extension is through composer.

Run

php composer.phar require pozitronik/yii2-cachedwidget "dev-master"

or add

"pozitronik/yii2-cachedwidget": "dev-master"

to the require section of your composer.json file.

Requirements

Yii2, PHP >= 7.2.0

Usage

Once the extension is installed, simply inherit any widgets from pozitronik\widgets\CachedWidget class instead of yii\base\Widget in your code.

CachedWidget has redefined render() method, that stores all rendered views in Yii2 global cache (with nested widgets, if its called in view file).

Widget handles correctly Yii2 view assets and inline resources, like js/css files or inline code inclusion.

Caching is disabled by default within YII_ENV_DEV environment (see $disable property).

Example

 class MyWidget extends \pozitronik\widgets\CachedWidget {
 // it is all, mostly
 }