Search

Laravel 5: Generating Paths Relative to the Configuration Directory With config_path

April 14, 2018 —John Koster

The config_path function can be used to retrieve the path the config directory. It can also be used to construct paths relative to the configuration directory by supplying a $path.

#Signature

The signature of the config_path function is:

1function config_path(
2 $path = ''
3);

#Example Use

The following examples will assume that the Laravel application is installed in the
/home/vagrant/Code/Laravel/ directory. The resulting path will appear above the function calls as a comment.

1// /home/vagrant/Code/Laravel/config/
2config_path();
3 
4// /home/vagrant/Code/Laravel/config/database.php
5config_path('database.php');
6 
7// /home/vagrant/Code/Laravel/config/app.php
8config_path('app.php');

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.