{"record":{"id":"5e49b46252e7a55a","repo":"yiisoft/yii2","slug":"the-fileinfo-php-extension-is-not-installed","errorCode":null,"errorMessage":"The fileinfo PHP extension is not installed.","messagePattern":"The fileinfo PHP extension is not installed\\.","errorType":"exception","errorClass":"InvalidConfigException","httpStatus":null,"severity":"error","filePath":"framework/helpers/BaseFileHelper.php","lineNumber":167,"sourceCode":"     * This will be passed as the second parameter to [finfo_open()](https://www.php.net/manual/en/function.finfo-open.php)\n     * when the `fileinfo` extension is installed. If the MIME type is being determined based via [[getMimeTypeByExtension()]]\n     * and this is null, it will use the file specified by [[mimeMagicFile]].\n     * @param bool $checkExtension whether to use the file extension to determine the MIME type in case\n     * `finfo_open()` cannot determine it.\n     * @return string|null the MIME type (e.g. `text/plain`). Null is returned if the MIME type cannot be determined.\n     * @throws InvalidConfigException when the `fileinfo` PHP extension is not installed and `$checkExtension` is `false`.\n     */\n    public static function getMimeType($file, $magicFile = null, $checkExtension = true)\n    {\n        if ($magicFile !== null) {\n            $magicFile = Yii::getAlias($magicFile);\n        }\n        if (!extension_loaded('fileinfo')) {\n            if ($checkExtension) {\n                return static::getMimeTypeByExtension($file, $magicFile);\n            }\n\n            throw new InvalidConfigException('The fileinfo PHP extension is not installed.');\n        }\n\n        $info = finfo_open(FILEINFO_MIME_TYPE, $magicFile);\n\n        if ($info) {\n            $result = finfo_file($info, $file);\n            // @link https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_finfo_close\n            // @link https://github.com/php/php-src/commit/ccb716dcadf60d989db48e4d2963e14d7dc63df3\n            if (PHP_VERSION_ID < 80500) {\n                finfo_close($info);\n            }\n\n            if ($result !== false) {\n                return $result;\n            }\n        }\n\n        return $checkExtension ? static::getMimeTypeByExtension($file, $magicFile) : null;","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/helpers/BaseFileHelper.php#L149-L185","documentation":"Error \"The fileinfo PHP extension is not installed.\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/helpers/BaseFileHelper.php:167 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}