How to know which version of Symfony I have?

前端 未结 11 1632
执念已碎
执念已碎 2020-12-07 19:35

I know that I have downloaded a Symfony2 project and started with but I have updated my vendor several times and I want to know which version of symfony I have

11条回答
  •  醉梦人生
    2020-12-07 20:13

    If you want to dynamicallly display your Symfony 2 version in pages, for example in footer, you can do it this way.

    Create a service:

    Register in service.yml

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

    And you can call it anywhere. In Controller, wrap it in JSON, or in pages example footer

     

    Built With Symfony {{ symfony_version() }} Version MIT License

    Now every time you run composer update to update your vendor, symfony version will also automatically update in your template.I know this is overkill but this is how I do it in my projects and it is working.

提交回复
热议问题