PHP code example of consik / yii2-fluent

1. Go to this page and download the library: Download consik/yii2-fluent library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

consik / yii2-fluent example snippets



use consik\yii2fluent\FluentComponentBehavior;

class Test extends \yii\base\Component
{
    public $isNew;
    public $comments;

    public function behaviors()
     {
         return [
            FluentComponentBehavior::className()
         ];
     }
}


use consik\yii2fluent\FluentComponentBehavior;

class Test extends \yii\base\Component
{
    public $isNew;
    public $comments;
    public $fluentUnaccessable;

    public function behaviors()
     {
         return [
            [
                'class' => FluentComponentBehavior::className(),
                'attributes' => [
                    'new' => 'isNew',
                    'comments'
                ]
         ];
     }
}


/*
 * Class YourClass
 * @method $this setProperty(string $name, $value)
 * @method $this unsetProperty(string $name)
 * @method $this addItemTo(string $arrName, mixed $item, bool $initOnEmpty = true)
 */
 class YourClass extends \yii\base\components { ... }
 array $attributes = []
 $this setProperty(string $property, mixed $value)
!empty() && !is_array()