【发布时间】:2021-04-12 05:57:12
【问题描述】:
我在一个项目中使用 Symfony 4.4,我需要使用 stfalcontinymce。因为我在 SF4 我need 2.4 版。所以我这样做了:
composer require stfalcon/tinymce-bundle=2.4
然后我得到这个错误:
!! 11:03:44 CRITICAL [php] Uncaught Error: Class 'Twig_Extension' not found ["exception" => Error { …}]
!!
!! In StfalconTinymceExtension.php line 13:
!!
!! Attempted to load class "Twig_Extension" from the global namespace.
!! Did you forget a "use" statement?
有人告诉我这是因为这个版本与 Twig 3 不兼容,所以我需要降级我的 Twig 版本。然后我这样做是为了降级 Twig:
composer require twig/twig=2
然后我得到这个错误:
13:14:07 CRITICAL [php] Uncaught Error: Call to undefined method Twig\Environment::registerUndefinedTokenPa
rserCallback() ["exception" => Error { …}]
!!
!! In srcApp_KernelDevDebugContainer.php line 2040:
!!
!! Attempted to call an undefined method named "registerUndefinedTokenParserCallback" of class "Twig\Environm ent".
!! Did you mean to call e.g. "registerUndefinedFilterCallback" or "registerUndefinedFunctionCallback"?
我尝试在 composer.json 中添加
"twig/extensions": "*"
然后 composer install,然后运行命令:
composer require stfalcon/tinymce-bundle=2.4 -W
我得到这个错误:
!! 13:49:04 CRITICAL [php] Uncaught Error: Call to undefined method
Twig\Environment::registerUndefinedTokenParserCallback() ["exception" => Error { …}]
!!
!! In srcApp_KernelDevDebugContainer.php line 2045:
!!
!! Attempted to call an undefined method named "registerUndefinedTokenParserCallback" of class "Twig\Environment".
!! Did you mean to call e.g. "registerUndefinedFilterCallback" or "registerUndefinedFunctionCallback"?
我真的迷路了。有人可以帮忙吗?谢谢
【问题讨论】:
-
能否包含 composer json 和 lock 文件。这让我们可以准确地看到安装了哪些库
-
相关帖子中的信息可能是问题所在。在github上看到这个问题线程github.com/symfony/symfony/issues/39734也许你需要指定
twig/extra-bundle的版本 -
我在发布我的问题之前已经看到了这个问题,但它并没有解决我的问题。
-
作为提示:您不应该完全安装 v2.4 - 有一个 2.4.1 版本修复了一些错误。最好使用适当的版本约束,例如
^2.4
标签: php symfony twig composer-php downgrade