PHP code example of vxm / yii2-js-params

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

    

vxm / yii2-js-params example snippets


use yii\web\Controller;

class TestController extends Controller
{

    public function actionTest()
    {
        return $this->render('test', [
            'jsParams' => [
                'test' => 'vxm'
            ]
        ]);
    }
}

'components' => [
    'view' => [
        'params' => [
            'jsParams' => ['test' => 'vxm']
        ]
    ]
]

'components' => [
    'view' => [
        'params' => [
            'jsParams' => function() {
            
                return ['identity' => Yii::$app->user->identity->toArray()]
            }
        ]
    ]
]