{"record":{"id":"55be0951ed0704b9","repo":"phalcon/cphalcon","slug":"you-must-provide-adapter-option-in-factory-confi","errorCode":null,"errorMessage":"You must provide 'adapter' option in factory config parameter.","messagePattern":"You must provide 'adapter' option in factory config parameter\\.","errorType":"exception","errorClass":"Phalcon\\Config\\Exceptions\\MissingConfigOption","httpStatus":null,"severity":"error","filePath":"phalcon/Config/ConfigFactory.zep","lineNumber":227,"sourceCode":"\n        this->checkConfigArray(config);\n\n        return config;\n    }\n\n    /**\n     * @param array $config\n     *\n     * @throws Exception\n     */\n    private function checkConfigArray(array config) -> void\n    {\n        if true !== isset(config[\"filePath\"]) {\n            throw new MissingConfigOption(\"filePath\");\n        }\n\n        if true !== isset(config[\"adapter\"]) {\n            throw new MissingConfigOption(\"adapter\");\n        }\n    }\n}\n","sourceCodeStart":209,"sourceCodeEnd":231,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Config/ConfigFactory.zep#L209-L231","documentation":"The companion check to filePath: the factory config array must also contain an 'adapter' key, otherwise MissingConfigOption('adapter') is thrown. Adapter inference from the file extension only happens for plain string input — with array input the adapter must be explicit.","triggerScenarios":"$factory->load(['filePath' => 'config.ini']) — the adapter key is missing, and even though the file has an extension, inference does not apply to arrays.","commonSituations":"Copying a partial config array that omits the adapter; assuming extension-based inference works the same for array input as for strings.","solutions":["Add the adapter key: ['adapter' => 'ini', 'filePath' => 'config.ini'] (json, php, yaml also valid)","Or pass just the path string so the factory infers the adapter from the extension"],"exampleFix":"// before\n$config = $factory->load(['filePath' => '/etc/myapp/config.ini']);\n\n// after\n$config = $factory->load([\n    'adapter'  => 'ini',\n    'filePath' => '/etc/myapp/config.ini',\n]);","handlingStrategy":"validation","validationCode":"$configArray = ['filePath' => '/etc/myapp/config.ini'];\n$configArray['adapter'] ??= pathinfo($configArray['filePath'], PATHINFO_EXTENSION);\nif (empty($configArray['adapter'])) {\n    throw new InvalidArgumentException('ConfigFactory config is missing the \"adapter\" key');\n}\n$config = $factory->load($configArray);","typeGuard":null,"tryCatchPattern":"try {\n    $config = $factory->load($configArray);\n} catch (\\Phalcon\\Config\\ConfigFactory\\Exception\\MissingConfigOption $e) {\n    if (strpos($e->getMessage(), 'adapter') !== false) {\n        // Derive the adapter from the extension and retry\n        $configArray['adapter'] = pathinfo($configArray['filePath'], PATHINFO_EXTENSION);\n        $config = $factory->load($configArray);\n    }\n}","preventionTips":["Array input needs an explicit 'adapter' key — extension inference only works for plain strings","Default the adapter from the file extension when building config arrays programmatically","Keep factory config construction in one helper so both keys are always set"],"tags":["phalcon","config","factory","missing-option","configuration"],"backgroundTag":"config-validation-failed","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}