phalcon/cphalcon · error · Phalcon\Config\Exceptions\MissingFileExtension

You need to provide the extension in the file path

Error message

You need to provide the extension in the file path

What it means

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.

Source

Thrown at phalcon/Config/ConfigFactory.zep:193

        ];
    }

    /**
     * @param mixed $config
     *
     * @return array
     * @throws Exception
     */
    protected function parseConfig(var config) -> array
    {
        var extension, oldConfig;

        if typeof config === "string" {
            let oldConfig = config,
                extension = pathinfo(config, PATHINFO_EXTENSION);

            if true  == empty(extension) {
                throw new MissingFileExtension();
            }

            let config = [
                "adapter"  : extension,
                "filePath" : oldConfig
            ];
        }

        if typeof config === "object" && config instanceof ConfigInterface {
            let config = config->toArray();
        }

        if typeof config !== "array" {
            throw new ConfigNotArrayOrObject();
        }

        this->checkConfigArray(config);

View on GitHub (pinned to b7419de9cd)

Solutions

  1. Rename the file to carry a real extension the factory knows (config.ini, config.json, config.php, config.yaml)
  2. Or pass an array instead of a string: ['adapter' => 'ini', 'filePath' => '/etc/myapp/config']
  3. Check templated paths for unsubstituted placeholders before calling load()

Example fix

// before
$config = $factory->load('/etc/myapp/config');

// after
$config = $factory->load([
    'adapter'  => 'ini',
    'filePath' => '/etc/myapp/config',
]);
Defensive patterns

Strategy: validation

Validate before calling

if (is_string($source) && pathinfo($source, PATHINFO_EXTENSION) === '') {
    throw new InvalidArgumentException(
        'Config path needs a file extension so ConfigFactory can pick the adapter: ' . $source
    );
}
$config = $factory->load($source);

Try / catch

try {
    $config = $factory->load($path);
} catch (\Phalcon\Config\ConfigFactory\Exception\MissingFileExtension $e) {
    // No extension to infer the adapter from; retry with an explicit definition
    $config = $factory->load(['adapter' => 'ini', 'filePath' => $path]);
}

Prevention

When it happens

Trigger: $factory->load('/etc/myapp/config') — extension-less file name. Dotfiles such as '/etc/myapp/.env' also yield an empty extension from pathinfo.

Common situations: Extension-less config names under /etc; hidden dotfiles; templated paths like 'config.{ENV}' where the placeholder never got substituted before load().

Related errors


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/d7b3bff926f7e8e8. Report an issue: GitHub.