{"record":{"id":"bb5b631db1eac80f","repo":"phalcon/cphalcon","slug":"yaml-extension-is-not-loaded","errorCode":null,"errorMessage":"Yaml extension is not loaded","messagePattern":"Yaml extension is not loaded","errorType":"exception","errorClass":"Phalcon\\Config\\Exceptions\\MissingYamlExtension","httpStatus":null,"severity":"error","filePath":"phalcon/Config/Adapter/Yaml.zep","lineNumber":70,"sourceCode":" * echo $config->phalcon->controllersDir;\n * echo $config->phalcon->baseuri;\n * echo $config->models->metadata;\n *```\n */\nclass Yaml extends Config\n{\n    use InfoTrait;\n    use YamlTrait;\n\n    /**\n     * Phalcon\\Config\\Adapter\\Yaml constructor\n     */\n    public function __construct( string filePath,  array callbacks = null)\n    {\n        var yamlConfig;\n\n        if unlikely !this->phpExtensionLoaded(\"yaml\") {\n            throw new MissingYamlExtension();\n        }\n\n        if empty(callbacks) {\n            let yamlConfig = this->phpYamlParseFile(filePath);\n        } else {\n            let yamlConfig = this->phpYamlParseFile(filePath, 0, callbacks);\n        }\n\n        if unlikely yamlConfig === null {\n            let yamlConfig = [];\n        }\n\n        if unlikely yamlConfig === false {\n            throw new CannotLoadConfigFile(basename(filePath));\n        }\n\n        parent::__construct(yamlConfig);\n    }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Config/Adapter/Yaml.zep#L52-L88","documentation":"Config\\Adapter\\Yaml requires the PECL yaml extension. Before parsing anything, the constructor checks extension_loaded('yaml'); if the extension is not active in the current PHP runtime, MissingYamlExtension is thrown regardless of whether the file is valid.","triggerScenarios":"Using new Yaml('app.yaml') on a machine where ext-yaml is not installed or not enabled — most default PHP builds and minimal Docker/CI images do not include it; the CLI SAPI using a different php.ini without the extension.","commonSituations":"Works on the dev machine but fails in Docker/CI/production; apt/pecl extension installed for the web SAPI but the extension line missing for CLI; upgrading PHP images and losing the custom extension.","solutions":["Install and enable the extension: pecl install yaml (or apt install php-yaml), then restart PHP/FPM","Or switch to an adapter with no extra dependency (Php, Ini, or Json)","Guard with extension_loaded('yaml') and fall back to another adapter when absent"],"exampleFix":"// before\n$config = new \\Phalcon\\Config\\Adapter\\Yaml(dirname(__DIR__) . '/config/app.yaml');\n\n// after\n$path = dirname(__DIR__) . '/config/app.yaml';\n$config = extension_loaded('yaml')\n    ? new \\Phalcon\\Config\\Adapter\\Yaml($path)\n    : new \\Phalcon\\Config\\Adapter\\Ini(preg_replace('/\\.ya?ml$/', '.ini', $path));","handlingStrategy":"fallback","validationCode":"if (!extension_loaded('yaml')) {\n    throw new RuntimeException(\n        'ext-yaml is required for the Yaml config adapter; install with: pecl install yaml'\n    );\n}\n$config = new \\Phalcon\\Config\\Adapter\\Yaml($path);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare the dependency explicitly: composer require ext-yaml so installs fail early when absent","In Dockerfiles add pecl install yaml && docker-php-ext-enable yaml","If environments vary, choose the adapter dynamically based on extension_loaded('yaml') and available files"],"tags":["phalcon","config","yaml","php-extension","environment"],"backgroundTag":"missing-php-extension","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}