首页 > 解决方案 > Symfony 无法加载 TextType 类

问题描述

我有 symfony 4.1 版,我先尝试安装 symfony/form 组件,截图如下:http: //prntscr.com/jqqvdl

接下来,我收到此错误 - http://prntscr.com/jqqxdg

错误:

无法加载类型“Symfony\Component\Form\Extension\Core\TextType”:类不存在。

任何人都知道如何修复这个 symfony 错误?

标签: phpsymfony

解决方案


事实上,正确的命名空间是:
Symfony\Component\Form\Extension\Core\Type\TextType

TextType在 下Symfony\Component\Form\Extension\Core\Type,见:

use Symfony\Component\Form\Extension\Core\Type\TextType;
//...
$form = $this->createFormBuilder()
    ->add('task', TextType::class)    
    ->getForm();

推荐阅读