{"record":{"id":"2101565ef91c5578","repo":"phalcon/cphalcon","slug":"configuration-file-filename-cannot-be-loaded-210156","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/Php.zep","lineNumber":61,"sourceCode":" * use Phalcon\\Config\\Adapter\\Php;\n *\n * $config = new Php(\"path/config.php\");\n *\n * echo $config->phalcon->controllersDir;\n * echo $config->database->username;\n *```\n */\nclass Php extends Config\n{\n    /**\n     * Phalcon\\Config\\Adapter\\Php constructor\n     *\n     * @throws CannotLoadConfigFile\n     */\n    public function __construct( string filePath)\n    {\n        if unlikely true !== is_file(filePath) {\n            throw new CannotLoadConfigFile(basename(filePath));\n        }\n\n        parent::__construct(\n            require filePath\n        );\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":69,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Config/Adapter/Php.zep#L43-L69","documentation":"Config\\Adapter\\Php loads a plain PHP file that returns an array. It first checks is_file(); anything that is not an existing regular file — missing path, a directory, or a dead symlink — throws CannotLoadConfigFile with the basename before require runs.","triggerScenarios":"new Php('config/config.php') where the file is absent; passing a directory path; a config.php symlink whose target (e.g. production.php) was never deployed.","commonSituations":"config.php excluded from the deploy package or .gitignore; environment-symlink pattern (config.php -> env/prod.php) with the target missing after a partial deploy.","solutions":["Check is_file() on the path before constructing","Use absolute paths instead of cwd-relative ones","If using environment symlinks, verify the link target ships with the artifact"],"exampleFix":"// before\n$config = new \\Phalcon\\Config\\Adapter\\Php('config/config.php');\n\n// after\n$path = dirname(__DIR__) . '/config/config.php';\nif (!is_file($path)) {\n    throw new RuntimeException('Missing config file: ' . $path);\n}\n$config = new \\Phalcon\\Config\\Adapter\\Php($path);","handlingStrategy":"validation","validationCode":"$path = dirname(__DIR__) . '/config/config.php';\nif (!is_file($path)) {\n    throw new RuntimeException('Config file missing (not a regular file): ' . $path);\n}\n$config = new \\Phalcon\\Config\\Adapter\\Php($path);","typeGuard":null,"tryCatchPattern":"try {\n    $config = new \\Phalcon\\Config\\Adapter\\Php($path);\n} catch (\\Phalcon\\Config\\Adapter\\Php\\Exception\\CannotLoadConfigFile $e) {\n    // is_file() failed: missing file, directory, or dead env symlink\n    throw new RuntimeException('Failed to load php config: ' . $path, 0, $e);\n}","preventionTips":["Check is_file() before constructing the adapter — directories and dead symlinks also fail","When using environment symlinks (config.php -> prod.php), deploy the target files too","Keep config.php out of .gitignore/deploy excludes unless it is generated"],"tags":["phalcon","config","php","file-path","configuration"],"backgroundTag":"config-file-load-failed","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}