lexxpavlov / LexxpavlovSettingsBundle

This bundle helps you to manage your settings in Symfony2/3 project
MIT License
10 stars 10 forks source link

Twig 3 upgrade: Attempted to load class "Twig_Extension" from the global namespace #14

Open magedan opened 3 years ago

magedan commented 3 years ago

Hello,

I was trying to upgrade my project to Twig 3 and got following error:

Attempted to load class "Twig_Extension" from the global namespace. Did you forget a "use" statement?

vendor/lexxpavlov/settingsbundle/Twig/SettingsExtension.php:

    namespace Lexxpavlov\SettingsBundle\Twig;

    use Lexxpavlov\SettingsBundle\Service\Settings;

    class SettingsExtension extends \Twig_Extension
    {
        /** @var Settings */
        private $settings;
        /**

Twig_Extension is deprecated since Twig version 2.7, it is required to use "Twig\Extension\AbstractExtension" instead in Twig 3.

It looks like we have two ways to deal with this situation:

  1. Fix Twig version in composer.json to 2.x.
  2. Bump Twig to ^3.0 and update SettingsExtension.php (BC break).

What would you suggest @lexxpavlov?