{"record":{"id":"d7b3bff926f7e8e8","repo":"phalcon/cphalcon","slug":"you-need-to-provide-the-extension-in-the-file-path","errorCode":null,"errorMessage":"You need to provide the extension in the file path","messagePattern":"You need to provide the extension in the file path","errorType":"exception","errorClass":"Phalcon\\Config\\Exceptions\\MissingFileExtension","httpStatus":null,"severity":"error","filePath":"phalcon/Config/ConfigFactory.zep","lineNumber":193,"sourceCode":"        ];\n    }\n\n    /**\n     * @param mixed $config\n     *\n     * @return array\n     * @throws Exception\n     */\n    protected function parseConfig(var config) -> array\n    {\n        var extension, oldConfig;\n\n        if typeof config === \"string\" {\n            let oldConfig = config,\n                extension = pathinfo(config, PATHINFO_EXTENSION);\n\n            if true  == empty(extension) {\n                throw new MissingFileExtension();\n            }\n\n            let config = [\n                \"adapter\"  : extension,\n                \"filePath\" : oldConfig\n            ];\n        }\n\n        if typeof config === \"object\" && config instanceof ConfigInterface {\n            let config = config->toArray();\n        }\n\n        if typeof config !== \"array\" {\n            throw new ConfigNotArrayOrObject();\n        }\n\n        this->checkConfigArray(config);\n","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Config/ConfigFactory.zep#L175-L211","documentation":"ConfigFactory::load() with a plain string infers which adapter to use from the file extension (pathinfo PATHINFO_EXTENSION). If the string carries no extension, MissingFileExtension is thrown because the factory cannot decide between Ini/Json/Php/Yaml.","triggerScenarios":"$factory->load('/etc/myapp/config') — extension-less file name. Dotfiles such as '/etc/myapp/.env' also yield an empty extension from pathinfo.","commonSituations":"Extension-less config names under /etc; hidden dotfiles; templated paths like 'config.{ENV}' where the placeholder never got substituted before load().","solutions":["Rename the file to carry a real extension the factory knows (config.ini, config.json, config.php, config.yaml)","Or pass an array instead of a string: ['adapter' => 'ini', 'filePath' => '/etc/myapp/config']","Check templated paths for unsubstituted placeholders before calling load()"],"exampleFix":"// before\n$config = $factory->load('/etc/myapp/config');\n\n// after\n$config = $factory->load([\n    'adapter'  => 'ini',\n    'filePath' => '/etc/myapp/config',\n]);","handlingStrategy":"validation","validationCode":"if (is_string($source) && pathinfo($source, PATHINFO_EXTENSION) === '') {\n    throw new InvalidArgumentException(\n        'Config path needs a file extension so ConfigFactory can pick the adapter: ' . $source\n    );\n}\n$config = $factory->load($source);","typeGuard":null,"tryCatchPattern":"try {\n    $config = $factory->load($path);\n} catch (\\Phalcon\\Config\\ConfigFactory\\Exception\\MissingFileExtension $e) {\n    // No extension to infer the adapter from; retry with an explicit definition\n    $config = $factory->load(['adapter' => 'ini', 'filePath' => $path]);\n}","preventionTips":["Give config files real extensions matching a known adapter (ini/json/php/yaml)","Remember dotfiles like .env have no PATHINFO_EXTENSION — pass an explicit array instead","Check templated paths for unsubstituted {ENV}-style placeholders before load()"],"tags":["phalcon","config","factory","file-extension","configuration"],"backgroundTag":"missing-file-extension","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}