ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

getting application path

May 23, 2011 5:21am

Subscribe [5]
  • #1 / May 23, 2011 5:21am

    introvert

    83 posts

    Hello,

    What is the easiest way to get CI application path, without need to set it manually in the configuration or code?

    BASEPATH variable will return system pat.

    Thanks for help

  • #2 / May 23, 2011 6:57am

    nil_php

    6 posts

    use getcwd() function.

  • #3 / May 23, 2011 7:22am

    InsiteFX's avatar

    InsiteFX

    6819 posts

    Constants
    APPPATH = application directory path
    SYSDIR = system directory path

    Look at index.php

    InsiteFX

  • #4 / Aug 31, 2011 1:07am

    cdevroe's avatar

    cdevroe

    13 posts

    Even though I’ve upgraded to the latest CodeIgniter the index.php continues to resolve the application path (APPPATH) as being inside the system directory. It appears to simply append $application_folder to BASEPATH. The latest version of CodeIgniter, I believe, moves the application directory outside of the system directory.

    On GitHub it appears that the index.php file has not changed. Am I missing something or should this be fixed? If it should I will create an issue on Github. If not, I’d like to know what I’m missing. Thanks in advance.

    index.php on Github

  • #5 / Aug 31, 2011 2:50am

    InsiteFX's avatar

    InsiteFX

    6819 posts

    You also need to update your index.php file with the new one

  • #6 / Aug 31, 2011 5:03pm

    bubbafoley's avatar

    bubbafoley

    189 posts

    SYSDIR is only the name of the system folder (i.e. ‘system’). BASEPATH is the full path to the system folder.

    index.php first checks $application_folder to see if it is a directory and then checks BASEPATH/$application_folder. If you moved your application folder somewhere else then you need to supply a full server path.

    // 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.'/');
    }
  • #7 / Aug 31, 2011 5:59pm

    cdevroe's avatar

    cdevroe

    13 posts

    index.php first checks $application_folder to see if it is a directory and then checks BASEPATH/$application_folder. If you moved your application folder somewhere else then you need to supply a full server path.

    A somewhat recent update to CodeIgniter moved the application folder outside of the system folder. So BASEPATH.’/’.$application_folder is no longer the correct location for this directory. Correct?

    Sorry if I’m missing something but my BASEPATH includes /system/ in it.

  • #8 / Aug 31, 2011 6:29pm

    bubbafoley's avatar

    bubbafoley

    189 posts

    A somewhat recent update to CodeIgniter moved the application folder outside of the system folder. So BASEPATH.ā€™/ā€™.$application_folder is no longer the correct location for this directory. Correct?

    They moved the default application folder path to outside the system folder in CI 2.0 but it’s fine to leave it inside the system folder. It will work fine either way.

    Sorry if Iā€™m missing something but my BASEPATH includes /system/ in it.

    Sorry if I confused you. BASEPATH is the full server path to your system folder. (i.e. “/var/www/mysite.com/codeigniter/system/”) so it is supposed to include the system folder.

    SYSDIR is just the name of the system folder without the rest of the path (i.e. “system”). I’m not sure why it’s in there because it’s not used anywhere in the core. I think maybe it’s something added for ExpressionEngine but I’m not sure.

  • #9 / Aug 31, 2011 11:15pm

    cdevroe's avatar

    cdevroe

    13 posts

    So shouldn’t APPPATH = ‘/full/path/to/application/’ and BASEPATH be ‘/full/path/to/system/’?  My my case APPPATH is ‘/wrong/path/to/system/application/’.

    I’ll just have to figure out why by going line by line (which I’ve done twice and can’t seem to find it).

    Here is my entire index.php from my app.

    https://gist.github.com/8435780f3d352ccb15dc

  • #10 / Aug 31, 2011 11:54pm

    bubbafoley's avatar

    bubbafoley

    189 posts

    and your files look like this?

    public_html/
    —application/
    —system/
    —index.php

    if you moved application and system then you need to use full paths.

  • #11 / Sep 01, 2011 12:48am

    cdevroe's avatar

    cdevroe

    13 posts

    and your files look like this?

    public_html/
    —application/
    —system/
    —index.php

    if you moved application and system then you need to use full paths.

    That is exactly right. The problem is, I’d like to keep this dynamic for my three environments: dev, staging, live.

  • #12 / Sep 01, 2011 2:54am

    bubbafoley's avatar

    bubbafoley

    189 posts

  • #13 / Sep 02, 2011 11:34am

    cdevroe's avatar

    cdevroe

    13 posts

    ah ok. you can do something like this https://raw.github.com/gist/b0fb248833620a05f7f4/5fc1cb7703ed94aaa67fa5bc7a9029c12ab884c2/CIindex.php

    Thanks! I did something very similar to this.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases