Make sure you have the correct config / main.php (this fi sample for the backend application that I used)
<?php $params = array_merge( require(__DIR__ . '/../../common/config/params.php'), require(__DIR__ . '/../../common/config/params-local.php'), require(__DIR__ . '/params.php'), require(__DIR__ . '/params-local.php') ); return [ 'id' => 'your-app-backend', 'name' => 'Your APP Backend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'backend\controllers', 'modules' => [], 'components' => [ 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], 'errorHandler' => [ 'errorAction' => 'site/error', ], ], 'params' => $params, ];
Assuming you have param.php with
<?php return [ 'adminEmail' => ' my_mail@example.com ', ];
you can get the parameter using yii :: $ app-> params
Yii::$app->params['adminEmail']))
for printing use
echo Yii::$app->params['adminEmail']))
scaisEdge
source share