arrow_back
Back

Yii2 application parameters: params.php and Yii::$app->params

Andrew Dorokhov Andrew Dorokhov schedule 1 min read

In the configuration files inside the config folder we can find the next includes:

// config/web.php
$config = [
    // ... other configuration settings ...
    'params' => require __DIR__ . '/params.php',
];
// config/params.php
return [
    'adminEmail' => 'admin@example.com',
    'supportEmail' => 'support@example.com',
];

We can access these parameters using the next way:

$email = Yii::$app->params['adminEmail']; // returns 'admin@example.com'
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Yii2 installation: Composer, requirements, and project templates

arrow_forward