{"record":{"id":"f174dfde343d4f6f","repo":"phalcon/cphalcon","slug":"configuration-file-filename-cannot-be-loaded","errorCode":null,"errorMessage":"Configuration file {fileName} cannot be loaded","messagePattern":"Configuration file (.+?) cannot be loaded","errorType":"exception","errorClass":"Phalcon\\Config\\Exceptions\\CannotLoadConfigFile","httpStatus":null,"severity":"error","filePath":"phalcon/Config/Adapter/Ini.zep","lineNumber":80,"sourceCode":"    use IniTrait;\n\n    /**\n     * Ini constructor.\n     *\n     * @param string $filePath\n     * @param int    $mode\n     *\n     * @throws Exception\n     */\n    public function __construct(string filePath, int mode = 1)\n    {\n        var directives, iniConfig, lastValue, path, section, sections;\n        array config;\n\n        let iniConfig = this->phpParseIniFile(filePath, true, mode);\n\n        if unlikely iniConfig === false {\n            throw new CannotLoadConfigFile(basename(filePath));\n        }\n\n        let config = [];\n\n        for section, directives in iniConfig {\n            if typeof directives === \"array\" {\n                let sections = [];\n\n                for path, lastValue in directives {\n                    let sections[] = this->parseIniString(\n                        (string) path,\n                        lastValue\n                    );\n                }\n\n                if !empty sections {\n                    let config[section] = call_user_func_array(\n                        \"array_replace_recursive\",","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Config/Adapter/Ini.zep#L62-L98","documentation":"Config\\Adapter\\Ini calls PHP's parse_ini_file(); when that returns false — the file cannot be read because it is missing or unreadable — CannotLoadConfigFile is thrown with the file's basename. The constructor does not pre-check existence, so any unreadable path lands here.","triggerScenarios":"new Ini('app/config/settings.ini') where the file does not exist, the relative path resolves from the wrong cwd, or the file lacks read permission for the runtime user.","commonSituations":"Environment-specific ini files absent on a new machine; cron/systemd running the script from another directory so relative paths break; permission changes after deploying as a different user.","solutions":["Check is_file() and is_readable() before constructing the adapter","Build absolute paths from __DIR__ / dirname(__DIR__)","Ensure the ini file ships with the deploy artifact and is readable by the web/CLI user"],"exampleFix":"// before\n$config = new \\Phalcon\\Config\\Adapter\\Ini('config/app.ini');\n\n// after\n$path = dirname(__DIR__) . '/config/app.ini';\nif (!is_readable($path)) {\n    throw new RuntimeException('Missing config file: ' . $path);\n}\n$config = new \\Phalcon\\Config\\Adapter\\Ini($path);","handlingStrategy":"validation","validationCode":"$path = dirname(__DIR__) . '/config/app.ini';\nif (!is_file($path) || !is_readable($path)) {\n    throw new RuntimeException('Config file missing or unreadable: ' . $path);\n}\n$config = new \\Phalcon\\Config\\Adapter\\Ini($path);","typeGuard":null,"tryCatchPattern":"try {\n    $config = new \\Phalcon\\Config\\Adapter\\Ini($path);\n} catch (\\Phalcon\\Config\\Adapter\\Ini\\Exception\\CannotLoadConfigFile $e) {\n    // Message has the basename; report the full path for the operator\n    throw new RuntimeException('Failed to load ini config: ' . $path, 0, $e);\n}","preventionTips":["Check is_file()/is_readable() before constructing the adapter","Use absolute paths built from __DIR__ so cron/systemd entry points cannot break them","Include config files in deploy verification (artifact checklist or boot smoke test)"],"tags":["phalcon","config","ini","file-path","configuration"],"backgroundTag":"config-file-load-failed","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}