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

1
  • this answer should help Commented Jan 22, 2015 at 20:56

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

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??
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.
htx will check it out tomorrow

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.