How do I know which version of Symfony I have?

I know that I downloaded the Symfony2 project and started from it, but I updated my provider several times and want to find out which version of symfony I have

Any idea?

+76
php symfony
May 30 '13 at 21:30
source share
7 answers

Run app/console --version (for Symfony3: bin/console --version ), this should give you a good idea. On my random project, the output is:

 Symfony version 2.2.0-DEV - app/dev/debug 

If you cannot access the console, try reading symfony/src/Symfony/Component/HttpKernel/Kernel.php , where the version is hardcoded , for example:

 const VERSION = '2.2.0'; 

Just in case you are curious, console creates an instance of Symfony\Bundle\FrameworkBundle\Console\Application . In this class constructor, he uses Symfony\Component\HttpKernel\Kernel::VERSION to initialize his parent constructor.

+129
May 30 '13 at 21:40
source share

Another way is to look at the source for Symfony\Component\HttpKernel\Kernel , for which const VERSION is defined. Github example

Locally this will be located at vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php .

+12
Jul 04 '14 at 13:12
source share

If you want to dynamically display the version of Symfony 2 on pages, for example, in the footer, you can do it like this.

create service

 <?php namespace Project\Bundle\DuBundle\Twig; class SymfonyVersionExtension extends \Twig_Extension { public function getFunctions() { return array( //this is the name of the function you will use in twig new \Twig_SimpleFunction('symfony_version', array($this, 'b')) ); } public function getName() { //return 'number_employees'; return 'symfony_version_extension'; } public function b() { $symfony_version = \Symfony\Component\HttpKernel\Kernel::VERSION; return $symfony_version; } } 

Register at service.yml

  dut.twig.symfony_version_extension: class: Project\Bundle\DutBundle\Twig\SymfonyVersionExtension tags: - { name: twig.extension } #arguments: [] 

And you can call him anywhere. In the controller, wrap it in JSON or in the footer

  <p> Built With Symfony {{ symfony_version() }} Version MIT License</p> 

Now, every time you run an update for the composer to update your provider, the symfony version also automatically updates in your template. I know this is too much, but this is how I do it in my projects and it works

+5
Dec 01 '15 at 2:37
source share

we can find the symfony version using the Kernel.php file, but the problem is that the location of Kernal Will will change from version to version (it is better to search for files in the Project directory)

in symfony 3.0: my_project \ provider \ Symfony \ Symfony \ SRC \ Symfony \ Component \ HttpKernel \ Kernel.php

Check Controller / PHP File

 $symfony_version = \Symfony\Component\HttpKernel\Kernel::VERSION; echo $symfony_version; // this will return version; **o/p:3.0.4-DEV** 
+3
Apr 14 '16 at 6:17
source share

if you are trying to use symfony version

try

symfony 2 +

cmd> php app / console --version

symfony 3+

cmd> php bin / console --version

eg

D: project> php bin / console --version

 Symfony 3.2.8 (kernel: app, env: dev, debug: true) 
+2
Aug 29 '17 at 9:11
source share

if you are in app_dev you can find the symfony version in the lower left corner of the page

+1
Jul 04 '14 at 13:05
source share

Inside your Symfony project, you can get the value in PHP as follows:

 $symfony_version = \Symfony\Component\HttpKernel\Kernel::VERSION; 
+1
Oct 06 '15 at 1:52
source share



All Articles