Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining a Root Path

I'm looking for a way to define a config variable as being the root path of my website. What's the nicest way to define this. I am using Codeigniter.

$config['root_path'] = ?

This is for my site_config file in my config folder.

/
/dev
/dev/application
/dev/application
/dev/application/config
/dev/application/config/site_config.php
/dev/system/
/dev/assets/
/public_html
like image 679
user1724167 Avatar asked May 19 '26 22:05

user1724167


1 Answers

I usually use __DIR__. For example, if your configuration file is in the root directory you can use:

$config['root_path']=__DIR__;

Or if it's in a subdirectory of the project (for example /anyframework/config/config.php):

$config['root_path']=dirname(dirname(__DIR__));
like image 90
Wolfgang Stengel Avatar answered May 21 '26 13:05

Wolfgang Stengel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!