yiisoft/yii2 · error · yii\base\InvalidConfigException

The font file does not exist: {$this->fontFile}

Error message

The font file does not exist: {$this->fontFile}

What it means

Error "The font file does not exist: {$this->fontFile}" thrown in yiisoft/yii2.

Source

Thrown at framework/captcha/CaptchaAction.php:121

     */
    public $fixedVerifyCode;
    /**
     * @var string|null the rendering library to use. Currently supported only 'gd' and 'imagick'.
     * If not set, library will be determined automatically.
     * @since 2.0.7
     */
    public $imageLibrary;


    /**
     * Initializes the action.
     * @throws InvalidConfigException if the font file does not exist.
     */
    public function init()
    {
        $this->fontFile = Yii::getAlias($this->fontFile);
        if (!is_file($this->fontFile)) {
            throw new InvalidConfigException("The font file does not exist: {$this->fontFile}");
        }
    }

    /**
     * Runs the action.
     */
    public function run()
    {
        if (Yii::$app->request->getQueryParam(self::REFRESH_GET_VAR) !== null) {
            // AJAX request for regenerating code
            $code = $this->getVerifyCode(true);
            Yii::$app->response->format = Response::FORMAT_JSON;
            return [
                'hash1' => $this->generateValidationHash($code),
                'hash2' => $this->generateValidationHash(strtolower($code)),
                // we add a random 'v' parameter so that FireFox can refresh the image
                // when src attribute of image tag is changed
                'url' => Url::to([$this->id, 'v' => uniqid('', true)]),

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/captcha/CaptchaAction.php:121 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17). Data as JSON: /api/errors/1796eab2d827aa6f. Report an issue: GitHub.