CodeIgniter报错:Unable to load the requested class: Config 求助
Hey there! As someone who’s messed around with CodeIgniter for years, let’s work through this error step by step—no need to panic, we’ll get this sorted.
First off, let’s clear up the confusion: Config is NOT a controller in CodeIgniter. It’s a core system class that handles loading and managing all your app’s configuration settings (like database credentials, base URLs, and more). That error means CodeIgniter can’t locate this critical core file when it tries to boot up.
Here’s how to start troubleshooting:
- Check if the core Config file exists: Navigate to your CodeIgniter installation’s
system/corefolder and confirmConfig.phpis there. Beta versions sometimes have missing files from incomplete downloads—if it’s gone, re-download the beta package and make sure all core files are extracted properly. - Watch for case sensitivity issues: CodeIgniter is strict about class name capitalization, especially on Linux/macOS. If any part of the code tries to load
config(lowercase) instead ofConfig(uppercase), that’ll trigger this error. Double-check any$this->load->library()calls or autoload settings that reference it. - Look for conflicting custom classes: If you (or the beta site’s developer) added a custom library named
Config.phpinapplication/libraries, it’ll clash with the core class. Rename that custom file/class to something unique (likeAppConfig.php) if that’s the case. - Validate the system path in index.php: Open your root
index.phpfile and check the$system_pathvariable. It should correctly point to yoursystemfolder (e.g.,$system_path = 'system';). If the path is wrong, CodeIgniter can’t find core classes like Config. - Check file permissions: On some local environments or servers, incorrect permissions can block CodeIgniter from reading core files. Make sure
system/core/Config.phphas read permissions set (usually 644 for files, 755 for folders). - Dig into error logs: Enable error logging in
application/config/config.php(set$config['log_threshold'] = 1;if it’s off) and check the logs inapplication/logs. The logs will often give specific details—like a missing file path or permission error—that the generic error message doesn’t show.
If none of these steps work, try re-downloading the beta site package entirely to ensure you have all the necessary files—beta versions can have bugs or incomplete setups that cause weird issues like this.
内容的提问来源于stack exchange,提问作者Eddie Taliaferro

