Best practice to display the version of a Symfony

2019-06-16 09:49发布

We built a web application build on top of the Symfony2 framework.

Now we need to display the current version of our software in the front end for the user to see. The version number is currently a tag in the git repository.

Now what is considered best practice to achieve this? The Composer documentation discourages the use of the version field used in the composer.json

Symfony itself seems to set the version string in the app/bootstrap.php.cache file: const VERSION ='2.7.6';

Is there any best practice regarding this issue? Is there a way to directly access the git tag name? Or should I go with the constant or composer.json way?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-06-16 10:01

with this example now you can do everything :

   \Symfony\Component\VarDumper\VarDumper::dump(\Symfony\Component\HttpKernel\Kernel::VERSION);

This is a Hardcoded const in source of symfony.

You can :

  • code your own const with this
  • function for request this info
  • trigger or listener
  • etc.....
查看更多
你好瞎i
3楼-- · 2019-06-16 10:24

You could try versioning-bundle. From their doc:

  • Adds additional parameter to your parameters.yml file and keeps it inline with your current application version.
  • Basic Version handlers implemented for manual and git tag versioning
查看更多
登录 后发表回答