0

I'm using Symfony 4.4 on a project and I need to use stfalcontinymce. Since I'm on SF4 I need the version 2.4. So I did this:

composer require stfalcon/tinymce-bundle=2.4

But then I get this error:

!!  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? 

Someone told me that it's because this version doesn't get along with Twig 3 so I need to downgrade my Twig version. I then did this to downgrade Twig:

composer require twig/twig=2

But then I get this error:

     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"?

I tried adding in composer.json

"twig/extensions": "*"

Then composer install, then running the command:

composer require stfalcon/tinymce-bundle=2.4 -W

And I get this error:

!!  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"?

I'm really lost here. Can someone help? thanks

Akame
  • 25
  • 1
  • 8
  • 2
    can you include the composer json and lock file. This allows us to see exactly what libraries are installed – JensV Jan 06 '21 at 14:05
  • This might also be related https://stackoverflow.com/q/65591937/2232127 – JensV Jan 06 '21 at 14:08
  • The info in the related post may be the issue. See this issue thread on github https://github.com/symfony/symfony/issues/39734 perhaps you need to specify the version of `twig/extra-bundle` – JensV Jan 06 '21 at 14:11
  • I had seen this issue before posting mine, but it didn't solve my problem. – Akame Jan 06 '21 at 14:37
  • As a hint: you should not install exactly v2.4 - there's a version 2.4.1 with some bugs fixed. Better use a proper version constraint like `^2.4` – Nico Haase Jan 06 '21 at 15:17

1 Answers1

2

Your executed commands don't seem to be possible on my system at all since there will be version constraint conflicts.

Instead of restricting to one version for your dependencies, you should use a constraint.

Your require in composer.json may contain something like the following

        "twig/twig": "^2",
        "stfalcon/tinymce-bundle": "2.4.*",
        "twig/extra-bundle": "^2"

The constraints are explained here. But the ^2 basically means >= 2.x.x and < 3.0.0

For the tinymce bundle I used the above because of the this GitHub issue

Furthermore twig/extensions seems to be deprecated, and this GitHub issue mentions twig/extra-bundle which is needed and may be its replacement.

JensV
  • 3,997
  • 2
  • 19
  • 43
  • Thanks it worked. I got confused with various version of the dependencies and got lost. I will keep in mind not to restrain the version of my dependencies. – Akame Jan 06 '21 at 14:38