CodeIgniter报错Unable to load the requested class: Config求助
Hey there, let's work through this annoying error you're facing. Even though Windows doesn't care about file name case, CodeIgniter's internal class loading has some quirks that can still cause this issue. Here are the most likely fixes to try:
First: Stop trying to autoload Config as a library
TheConfigclass is a core CodeIgniter component—it's automatically available in your controllers and models via$this->config, and you can access it globally withget_instance()->configif you're working outside those contexts. Adding it to$autoload['libraries']inapplication/config/autoload.phpis unnecessary and might actually be causing the conflict. Remove it from that array first and see if the error goes away.Verify the core Config file is intact
Navigate tosystem/core/Config.phpand confirm:- The file exists and isn't corrupted
- The class inside is named exactly
CI_Config(with the underscore)
CodeIgniter maps the lowercase'config'string to this core class, so if the filename or class name is modified, the loader will fail even on Windows.
Check for custom config file conflicts
If you've created a custom config file inapplication/config/named something likeConfig.php(with a capital C), Windows might treat it as the same asconfig.php, but CodeIgniter's loader will get confused. Rename any custom config files to use lowercase and unique names (e.g.,my_app_settings.php) instead of using the core class name.Ensure manual loading uses lowercase
If you're manually loading the class anywhere (which you shouldn't need to, but just in case), make sure you use the lowercase string:$this->load->library('config'); // Correct // Avoid: $this->load->library('Config'); // Can cause loading issuesEven Windows ignores case, CodeIgniter's loader uses the exact string you pass to resolve the core class, so sticking to lowercase is the safe bet.
Clear any cached files
If you have any caching enabled (file-based, APC, etc.), clear the cache. Stale cached class definitions can sometimes cause loading glitches, even on Windows.
Give these steps a shot—chances are one of them will fix the problem. If you're still stuck, feel free to share more details about where you're seeing the error (controller, model, custom script?) and we can dig deeper.
内容的提问来源于stack exchange,提问作者Recency

