Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PeregrineStudios's avatar

Custom App Config Settings?

Hi all - how would I implement custom config settings for a Laravel installation?

For example, in Yii, I can add custom fields to the web config file, under params, and access it like Yii::app()->params['adminEmail'] (for example). Then I can just swap out the email address in the config file if it ever needs to change. How would I accomplish something similar in Laravel?

0 likes
2 replies
kpasokhi's avatar
kpasokhi
Best Answer
Level 1

You can add custom config files in /config directory for example myapp.php, formatting is like this:

  <?php

    return [
            'name' => 'Joe'
  ];

Then you can set and get config values like this:

$value = config('myapp.name');

config(['myapp.name' => 'Bob']);
Emtized's avatar

Hi

You Can Add a custom setting params as below :


    'adminEmail' => 'admin@admin',

And you can access is in your app like this


config('app.adminEmail') ,

also you can add a variable in your .env file like this

    'adminEmial' => env('AdminEmail', 'admin@admin'),

this code get .env file content first if there is not data will be overwrite by your config data

Hope this help

Please or to participate in this conversation.