升级到Symfony 2.2后出现“Class'Twig_SimpleFunction'错误”

时间:2013-12-12 17:09:21

标签: php symfony twig symfony-2.2

我最近将Symfony从2.1更新到2.2,现在我收到了错误:

错误:在vendor / symfony / symfony / src / Symfony / Bundle / SecurityBundle / Twig / Extension / LogoutUrlExtension.php第41行中找不到类'Twig_SimpleFunction'

我的composer.json:

...
"require": {
    "php": ">=5.4",
    "symfony/symfony": "2.2.*",
    "twig/twig": "1.11.x",
    "twig/extensions": "1.0.x-dev",
    "noetix/easy-csv": "dev-master",
    "symfony/assetic-bundle": "2.*",
    "symfony/swiftmailer-bundle": "2.*",
    "symfony/monolog-bundle": "2.*",
    "sensio/distribution-bundle": "2.*",
    "sensio/framework-extra-bundle": "2.*",
    "sensio/generator-bundle": "2.*",
    "jms/security-extra-bundle": "1.4.*",
    "jms/di-extra-bundle": "1.3.*",
    "jms/serializer": "0.12.*",
    "jms/serializer-bundle" : "0.12.*@dev",
    "jms/metadata" : "1.3.*",
    "friendsofsymfony/user-bundle": "patch-1-dev",
    "friendsofsymfony/jsrouting-bundle": "1.2.*",
    "propel/propel1": ">=1.6.7",
    "propel/propel-bundle": "1.2.x-dev",
    "willdurand/propel-typehintable-behavior": "dev-master",
    "pagerfanta/pagerfanta": "1.0.x-dev",
    "white-october/pagerfanta-bundle": "dev-master",
    "knplabs/knp-menu-bundle": "dev-master",
    "knplabs/knp-menu": "2.0.x-dev",
    "exercise/elastica-bundle": "dev-master",
    "gregwar/captcha-bundle": "dev-master",
    "nelmio/api-doc-bundle": "2.1.*",
    "fr3d/ldap-bundle": "2.0.*@dev",
    "conjecto/easyrdf-bundle": "dev-master"
},
...

Twig deprecated features page说:“从Twig 1.x开始,使用Twig_SimpleFunction”。我有1.11,所以我不明白我做错了。

2 个答案:

答案 0 :(得分:1)

找到它。我怀疑问题在于无效的依赖关系。我下载了Symfony2.2.11并相应地更改了我的composer.json(注意不再引用twig,并更改了一些symfony / *和sensio / *依赖项):

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.2.*",
    "twig/extensions": "1.0.*",
    "noetix/easy-csv": "dev-master",
    "symfony/assetic-bundle": "2.1.*",
    "symfony/swiftmailer-bundle": "2.2.*",
    "symfony/monolog-bundle": "2.2.*",
    "sensio/distribution-bundle": "2.2.*",
    "sensio/framework-extra-bundle": "2.2.*",
    "sensio/generator-bundle": "2.2.*",
    "jms/security-extra-bundle": "1.4.*",
    "jms/di-extra-bundle": "1.3.*",
    "jms/serializer": "0.12.*",
    "jms/serializer-bundle" : "0.12.*@dev",
    "jms/metadata" : "1.3.*",
    "friendsofsymfony/user-bundle": "patch-1-dev",
    "friendsofsymfony/jsrouting-bundle": "1.2.*",
    "propel/propel1": ">=1.6.7",
    "propel/propel-bundle": "1.2.x-dev",
    "willdurand/propel-typehintable-behavior": "dev-master",
    "pagerfanta/pagerfanta": "1.0.x-dev",
    "white-october/pagerfanta-bundle": "dev-master",
    "knplabs/knp-menu-bundle": "dev-master",
    "knplabs/knp-menu": "2.0.x-dev",
    "exercise/elastica-bundle": "dev-master",
    "gregwar/captcha-bundle": "dev-master",
    "nelmio/api-doc-bundle": "2.1.*",
    "fr3d/ldap-bundle": "2.0.*@dev",
    "conjecto/easyrdf-bundle": "dev-master"
},

这个安装了枝条1.15,一切正常。 The manual page有错误 - Twig_SimpleFunction出现在> 1.11和< = 1.15之间,而不是1.x。

答案 1 :(得分:0)

Twig扩展类未命名空间。你有没有检查过你没有改变它?

在您的扩展程序类中,您应该使用\Twig_SimpleFunction,而不仅仅是Twig_SimpleFunction