Application directory path

Go To StackoverFlow.com

0

How can I get the application directory path in CodeIgniter? Is there any 'not dirty' way to do that?

I was looking through the constants but the most closer one I found was the BASEPATH which returns a full path to the /system directory, so basicly I can str_replace system with the application - but I'm just curious, is there any other clean and short way to get application directory path?

2012-04-03 20:53
by Cyclone
IIRC, there's the APPPATH constan - Damien Pirsy 2012-04-03 21:00


5

its in your index.php file ( this was taken from CI 2.1 , and its called APPPATH )

    // The path to the "application" folder
if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ( ! is_dir(BASEPATH.$application_folder.'/'))
    {
        exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}
2012-04-04 08:43
by Zaher


2

I believe you can accomplish this with the APPPATH variable.

So to get to your controllers folder it'd be something like.

include(APPPATH . 'controllers/')

Or whatever you wanted to do with it. Note the trailing slash is included in the APPPATH variable.

2012-04-03 21:01
by Matt Moore
APPPATH does return simply application/ and nothing more - I need a full path to write files in the cache - Cyclone 2012-04-03 21:03
Ads