PHP code example of ijackua / yii2-gon

1. Go to this page and download the library: Download ijackua/yii2-gon 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/ */

    

ijackua / yii2-gon example snippets


'components' => array(
    'gon' => 'ijackua\gon\GonComponent'
),

$config = array(
    'bootstrap' => array('gon'),
    ...

'components' => array(
       'gon' => array(
            'class' => 'ijackua\gon\GonComponent',
            'jsVariableName' => 'gon',
            'globalData' => ['g1' => 1, 'g2' => '2'],
            'showEmptyVar' => true,
        )
),

\Yii::$app->gon->push('someObj', ['a'=>'b']);
\Yii::$app->gon->push('str', 'hello');