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
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__));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With