phalcon/cphalcon · error · Phalcon\Config\Exceptions\MissingConfigOption
You must provide 'adapter' option in factory config paramete
Error message
You must provide 'adapter' option in factory config parameter.
What it means
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.
Source
Thrown at phalcon/Config/ConfigFactory.zep:227
this->checkConfigArray(config);
return config;
}
/**
* @param array $config
*
* @throws Exception
*/
private function checkConfigArray(array config) -> void
{
if true !== isset(config["filePath"]) {
throw new MissingConfigOption("filePath");
}
if true !== isset(config["adapter"]) {
throw new MissingConfigOption("adapter");
}
}
}
View on GitHub (pinned to b7419de9cd)
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
Example fix
// before
$config = $factory->load(['filePath' => '/etc/myapp/config.ini']);
// after
$config = $factory->load([
'adapter' => 'ini',
'filePath' => '/etc/myapp/config.ini',
]); Defensive patterns
Strategy: validation
Validate before calling
$configArray = ['filePath' => '/etc/myapp/config.ini'];
$configArray['adapter'] ??= pathinfo($configArray['filePath'], PATHINFO_EXTENSION);
if (empty($configArray['adapter'])) {
throw new InvalidArgumentException('ConfigFactory config is missing the "adapter" key');
}
$config = $factory->load($configArray); Try / catch
try {
$config = $factory->load($configArray);
} catch (\Phalcon\Config\ConfigFactory\Exception\MissingConfigOption $e) {
if (strpos($e->getMessage(), 'adapter') !== false) {
// Derive the adapter from the extension and retry
$configArray['adapter'] = pathinfo($configArray['filePath'], PATHINFO_EXTENSION);
$config = $factory->load($configArray);
}
} Prevention
- 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
When it happens
Trigger: $factory->load(['filePath' => 'config.ini']) — the adapter key is missing, and even though the file has an extension, inference does not apply to arrays.
Common situations: Copying a partial config array that omits the adapter; assuming extension-based inference works the same for array input as for strings.
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- You must provide 'filePath' option in factory config paramet
- You need to provide the extension in the file path
- Config must be array or Phalcon\Config\Config object
- To use 'array' adapter you have to specify the 'config' as a
- Configuration file {fileName} cannot be loaded
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/55be0951ed0704b9.
Report an issue: GitHub.