Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does laravel load config files

All laravel configuration files are found inside the config directory and all of them are returned as an associative array

//for example Session.php
return[

   /******************************
   * session name
   ******************************/
   "name" => "newBlog"
]; 

Later on this configuration can be used like this

Config::get("session.name");

How does this method get works ?? is it using require to require all these files ??? i tried to find the file of the config class but i didn't get the logic Illuminate\Support\Facades\Config i cant find the get method

so please how is this implemented ??? what's the logic behind?

like image 931
jimy razit Avatar asked Sep 08 '17 18:09

jimy razit


People also ask

How get data from config file in Laravel?

We use the config() method to get values from files in the config directory. We use the dot notation to get the value we want. The first parameter we use is the file's name without the . php extension.

Where is the Laravel config file?

Laravel's filesystem configuration file is located at config/filesystems.php . Within this file, you may configure all of your filesystem "disks". Each disk represents a particular storage driver and storage location.

What is the use of config folder in Laravel?

All of the configuration files for the Laravel framework are stored in the app/config directory. Each option in every file is documented, so feel free to look through the files and get familiar with the options available to you.

What is config in Laravel?

Laravel configuration allows you to define per-environment configuration with the excellent vlucas/phpdotenv package. If you are new to Laravel, you might not yet know how you can create your configuration files in your projects and a few other helpful things that will help you master configuration.


1 Answers

It is in Illuminate\Config\Repository

public function get($key, $default = null)
{
    return Arr::get($this->items, $key, $default);
}

Further, instead of Config facade, you can use config helper as config('session.name')

like image 144
Pubudu Jayawardana Avatar answered Sep 23 '22 03:09

Pubudu Jayawardana