1

Can I somehow detect inside the code which version of symfony is currently used?
I have a bundle which uses a symfony function that has changed in version 2.4 so I need to detect on which version I am running, so that the function which is adequate for the used symfony version will be called

Nickolaus
  • 4,785
  • 4
  • 38
  • 60
  • [this](http://stackoverflow.com/questions/16846189/how-to-know-which-version-of-symfony-i-have) answer should help – Scriptable Jan 22 '15 at 20:56

1 Answers1

2

The symfony version constant will help you.

You find it in Symfony/Component/HttpKernel/Kernel - constant VERSION.

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Kernel.php#L62

Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • will $this->get('kernel')->getBundle(..) work to get the class or what do I have to use, because the Symfony Components are not an actual bundle... or can I use the class loader?? – Nickolaus Jan 22 '15 at 21:09
  • Hmm.. the kernel class is often loaded by the classloader, because of `$kernel = new HttpKernel($dispatcher, $resolver);`. I would first try `echo $kernel::VERSION` and then `echo Symfony/Component/HttpKernel/Kernel::VERSION`. – Jens A. Koch Jan 22 '15 at 21:21
  • htx will check it out tomorrow – Nickolaus Jan 22 '15 at 21:22