Download the PHP package iluhansk/yii2-lazy without Composer
On this page you can find all versions of the php package iluhansk/yii2-lazy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download iluhansk/yii2-lazy
More information about iluhansk/yii2-lazy
Files in iluhansk/yii2-lazy
Download iluhansk/yii2-lazy
More information about iluhansk/yii2-lazy
Files in iluhansk/yii2-lazy
Vendor iluhansk
Package yii2-lazy
Short Description implementation pattern design 'lazy load' for components of yii2
License GPL-3.0+
Package yii2-lazy
Short Description implementation pattern design 'lazy load' for components of yii2
License GPL-3.0+
Please rate this library. Is it a good library?
Informations about the package yii2-lazy
yii2-lazy
implementation pattern design "lazy load" for components of yii2
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Usage
Add LazyBehavior to target class and define methods corresponding lazy properties:
namespace common\components; use \yii\base\Component; use iluhansk\renderer\LazyBehavior; /** * @property int $passengersCount Count of passengers in the car */ class Car extends Component { public function behaviors() { return [ 'lazy' => [ 'class' => LazyBehavior::className() ], ]; } public function lazy_passengersCount() { //some logic here, for example: return rand(1,4); } }
And use lazy property in any place:
use common\components\Car; echo "PassengersCount first call: $o->passengersCount
"; //first use lazy property will call lazy_passengersCount method of object echo "PassengersCount second call: $o->passengersCount
"; //this will return stored value (and not call lazy_passengersCount method again)
All versions of yii2-lazy with dependencies
PHP Build Version
Package Version
Requires
yiisoft/yii2 Version
*
The package iluhansk/yii2-lazy contains the following files
Loading the files please wait ....