Best practice to display the version of a Symfony application to the user?

孤街醉人 提交于 2019-12-08 19:09:04

问题


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?


回答1:


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



回答2:


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.....


来源:https://stackoverflow.com/questions/35014819/best-practice-to-display-the-version-of-a-symfony-application-to-the-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!