34 C
Jaipur
Tuesday, October 20, 2020

How To Create Config File In Laravel – Linux Hint

Must read

4 Best Terminal Browsers for Linux Command Line

I’m guessing that you are probably using Firefox or a Chrome-based browser like Brave to read this article. Or, maybe, Google Chrome or Chromium....

Foxconn: Foxconn says it will continue to work with Wisconsin to create jobs, woo investors – Latest News

Taiwan-based Foxconn Technology Group said its commitment to Wisconsin has not wavered and it will continue to work with US President Donald Trump and...

The core settings of your Laravel application – database connection, queue and mail settings, etc. – live in files in the config folder. Each of these files returns an array, and each value in the array will be accessible by a config key that is comprised of the file-name and all descendant keys, separated by dots ( .)

So, if you create a file at config/services.php that looks like this:

// config/services.php
return [
    ‘keys’ =>
        [    
            ‘secret’ => ‘123456’
        ]
];

you will now have access to that config variable using

config(‘keys.keys.secret’)

Any configuration variables that should be distinct for each environment (and therefore not committed to source control) will instead live in your .env files.

Let’s say you want to use a different Bugsnag API key for each environment. You’d set the config file to pull it from .env:

<?php
// config/services.php
return [
   ‘bugsnag’ => [
       ‘api_key’ => env(‘BUGSNAG_API_KEY’)
    ];
]

This env( ) helper function pulls a value from your .env file with that same key. So now, add that key to your .env (settings for this environment) and .env.example (template for all environments) files:

BUGSNAG_API_KEY=oinfp9813410942

Your .env file already contains quite a few environment-specific variables needed by the framework, like which mail driver you’ll be using and what your basic database settings are

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

4 Best Terminal Browsers for Linux Command Line

I’m guessing that you are probably using Firefox or a Chrome-based browser like Brave to read this article. Or, maybe, Google Chrome or Chromium....

Foxconn: Foxconn says it will continue to work with Wisconsin to create jobs, woo investors – Latest News

Taiwan-based Foxconn Technology Group said its commitment to Wisconsin has not wavered and it will continue to work with US President Donald Trump and...

Call Of Duty Mobile Season 11 Review: The Best COD Mobile Update So Far

Call Of Duty Mobile recently released the much-awaited Season 11 update. What’s unique about this season is that it also celebrates Call of...