{"record":{"id":"016d814d7c6029db","repo":"phalcon/cphalcon","slug":"to-use-array-adapter-you-have-to-specify-the-co","errorCode":null,"errorMessage":"To use 'array' adapter you have to specify the 'config' as an array.","messagePattern":"To use 'array' adapter you have to specify the 'config' as an array\\.","errorType":"exception","errorClass":"Phalcon\\Config\\Exceptions\\GroupedAdapterRequiresArray","httpStatus":null,"severity":"error","filePath":"phalcon/Config/Adapter/Grouped.zep","lineNumber":124,"sourceCode":"                if \"\" === defaultAdapter {\n                    this->merge(\n                        configFactory->load(configName)\n                    );\n\n                    continue;\n                }\n\n                let configInstance = [\n                    \"filePath\" : configName,\n                    \"adapter\"  : defaultAdapter\n                ];\n            } elseif !isset configInstance[\"adapter\"] {\n                let configInstance[\"adapter\"] = defaultAdapter;\n            }\n\n            if \"array\" === configInstance[\"adapter\"] {\n                if !isset configInstance[\"config\"] {\n                    throw new GroupedAdapterRequiresArray();\n                }\n\n                let configArray    = configInstance[\"config\"],\n                    configInstance = new Config(configArray, this->insensitive);\n            } else {\n                let configInstance = configFactory->load(configInstance);\n            }\n\n            this->merge(configInstance);\n        }\n    }\n}\n","sourceCodeStart":106,"sourceCodeEnd":137,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Config/Adapter/Grouped.zep#L106-L137","documentation":"In Config\\Adapter\\Grouped, an entry using 'adapter' => 'array' must carry its actual settings under a 'config' key, because the array adapter reads raw data instead of a file. Without 'config', GroupedAdapterRequiresArray is thrown. Entries without an explicit adapter inherit defaultAdapter, so a default of 'array' combined with file-name entries triggers it too.","triggerScenarios":"new Grouped([['adapter' => 'array', 'filePath' => 'config.php']]) — filePath is meaningless here and the required 'config' key is missing. Also new Grouped(['base.ini'], 'array') where the plain file entry inherits 'array' as adapter.","commonSituations":"Merging file-based entries (ini/yaml) with one in-memory array entry and forgetting the config key; switching a project's defaultAdapter to 'array' while existing entries still only name files.","solutions":["Add the config key: ['adapter' => 'array', 'config' => ['db' => ['host' => 'localhost']]]","If the data really lives in a file, use the matching file adapter (ini/json/yaml/php) with filePath instead","When using a non-array defaultAdapter, still give array entries an explicit 'adapter' and 'config'"],"exampleFix":"// before\nnew Grouped([\n    ['adapter' => 'array', 'filePath' => 'config.php'],\n    'app.ini',\n]);\n\n// after\nnew Grouped([\n    ['adapter' => 'array', 'config' => ['app' => ['name' => 'cli']]],\n    'app.ini',\n]);","handlingStrategy":"validation","validationCode":"$entries = [\n    ['adapter' => 'array', 'config' => ['app' => ['name' => 'cli']]],\n    'app.ini',\n];\nforeach ($entries as $i => $entry) {\n    if (is_array($entry) && ($entry['adapter'] ?? '') === 'array' && !isset($entry['config'])) {\n        throw new InvalidArgumentException(sprintf(\n            'Grouped entry #%d: the \"array\" adapter requires a \"config\" key',\n            $i\n        ));\n    }\n}\n$config = new \\Phalcon\\Config\\Adapter\\Grouped($entries);","typeGuard":null,"tryCatchPattern":"try {\n    $config = new \\Phalcon\\Config\\Adapter\\Grouped($entries);\n} catch (\\Phalcon\\Config\\Adapter\\Grouped\\Exception\\GroupedAdapterRequiresArray $e) {\n    // An 'array'-adapter entry lacks its 'config' payload; fall back to the file entry alone\n    $config = new \\Phalcon\\Config\\Adapter\\Grouped(\n        array_values(array_filter($entries, 'is_string'))\n    );\n}","preventionTips":["Every 'array'-adapter entry must carry its data under a 'config' key","Do not set defaultAdapter to 'array' when entries are file names","Keep a unit test that constructs your Grouped config from the real entries array"],"tags":["phalcon","config","grouped","adapter","configuration"],"backgroundTag":"config-validation-failed","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}