2.5.9的Symfony表单类型不再被识别,但仍使用2.5.9

时间:2017-10-26 09:19:08

标签: symfony composer-php

我正在使用Symfony 2.5.9并且最近运行了composer update。在我现在获得的表单页面上:

  

InvalidArgumentException:无法加载类型“Symfony \ Component \ Form \ Extension \ Core \ Type \ TextType”(0)

在更新之前,该页面呈现正常。表格是

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormError;

class TaskType extends AbstractType {

  public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('name')
                ->add('info', 'text', array());
    }

  public function getName() {
        return 'myapp_mybundle_tasktype';
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'MyApp\MyBundle\Entity\Task'
        ));
    }

}

阅读其他一些posts,这似乎是因为在Symfony 3中不再使用上面创建表单元素类型的方法。但我现在需要使用2.5.9。

即使我从master分支复制并粘贴composer.json(即未受影响且正常工作)并运行composer update,我也会遇到同样的错误。

我还尝试从供应商文件夹中删除所有内容并刷新两个缓存,然后重新运行composer update但页面加载时会出现相同的错误。怎么会这样?而不是使用变通方法,这个需求变化的原因是什么?我仍然在开发工具栏中看到Symfony 2.5.9。

作曲家档案:

{
    "autoload": {
        "psr-0": {
            "": "src/"
        },
        "classmap": ["vendor/MediovskiTechnology/php-crontab-manager/src/"]
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.5.9",
        "symfony/console": "2.5.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "1.2",
        "twig/extensions": "1.1.*@dev",
        "symfony/assetic-bundle": "2.3.*",
        "symfony/swiftmailer-bundle": "2.3.7",
        "symfony/monolog-bundle": "2.6.*",
        "sensio/distribution-bundle": "3.0.*",
        "sensio/framework-extra-bundle": "3.0.*",
        "sensio/generator-bundle": "2.3.*",
        "jms/security-extra-bundle": "1.5.*",
        "jms/di-extra-bundle": "1.4.*",
        "kriswallsmith/assetic": "~1.1",
        "phpoffice/phpexcel": "1.8.0",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "doctrine/data-fixtures": "1.0.*@dev",
        "kriswallsmith/buzz": "dev-master",
        "mlpz/postmark-bundle": "dev-master",
        "friendsofsymfony/jsrouting-bundle": "2.0.*@dev",
        "jms/serializer-bundle": "*",
        "monolog/monolog": "1.10.0",
        "querypath/querypath": "dev-master",
        "MediovskiTechnology/php-crontab-manager": "0.9.3",
        "mtdowling/cron-expression": "1.1.0",
        "drak/native-session": "*",
        "egulias/email-validator": "~1.2",
        "swiftmailer/swiftmailer": "5.2.1",
        "twilio/sdk": "^5.4",
        "hybridauth/hybridauth": "2.6.0",
        "symfony/doctrine-bridge": "~2.7"
    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
        ]
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    }
}

1 个答案:

答案 0 :(得分:0)

我通过更改

来修复此问题
"doctrine/doctrine-fixtures-bundle": "dev-master",

"doctrine/doctrine-fixtures-bundle": "2.3.0",