• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Default application path doesn't work

I just did an upgrade from 1.7 to 2, and my controller is not loading. Here's why:

1. The v.2 installation now has the application and system directories side by side in the web root. So I used that structure; I moved all my custom or modified files from /system/application to /application.

2. The new index.php defines an application folder with a relative string by default:

$application_folder = 'application';

3. APPPATH is defined with this conditional:

if (is_dir($application_folder))
        define('APPPATH', $application_folder.'/');
        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.'/');

The first block executes, because from this context (in the webroot), the relative path does exist, so I end up with an APPPATH of "application/"

Again, this is all default.

4. But in /system/core/Codeigniter.php, this include of the default controller file fails:

Because now in this context (within /system/core/) the relative path that it's looking for does NOT exist: "application/controllers/welcome.php"

It would if the application directory were still in /system, but that's not the default file structure in v.2.

So, granted, I know how to fix this. But I want to know what I'm missing: I can't figure out how this would ever work with a default install.

Hold the phone. I was wrong. The file is getting included correctly either way. Something is happening in the file itself that's stopping execution.

But I'd still like to know what I'm not understanding. How can the relative include path "application/" work from within /system/core/Codeigniter.php"?

Include paths are relevant to the current working directory, which is the location of index.php. Codeigniter.php is included, but is not the file being executed.

Duh. Wow, this was one of those times where, by the time I figured out where the problem actually was, I was too disoriented to think straight.

And by the way, the reason my controller class was failing was because I was extending my own MY_Controller class; in v1.7 that resided in /libraries, which is where I still had it, but in v2 it should reside in /core. So the file wasn't being found. I wonder why CodeIgniter wasn't made to throw an error when it can't find a class file in the autoload (and why PHP doesn't throw an error when I try to extend a class that doesn't exist).

Maybe because your error_reporting is set to 0 (no error reports)

No, it's not.

define('ENVIRONMENT', 'development');

if (defined('ENVIRONMENT'))
    switch (ENVIRONMENT)
        case 'development':
        case 'testing':
        case 'production':

            exit('The application environment is not set correctly.');

I think you should check your php configuration, I tried creating a MY_Controller in application/libraries, autoloaded it, and extended it. Then an error occurred on my page,
Quote:Fatal error: Class 'MY_Controller' not found

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.