如何获得PHP中的Subversion版本号? [英] How can I get the Subversion revision number in PHP?

查看:82
本文介绍了如何获得PHP中的Subversion版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的PHP应用程序标有使用的版本号,但我不想使用

I want to have my PHP application labeled with the revision number which it uses, but I don't want to use CruiseControl or update a file and upload it every time. How should I do it?

推荐答案

SVN关键字不是一个好的解决方案.正如其他人指出的那样,在文件中添加$ Revision $仅会影响特定文件,该文件可能不会长期更改.

SVN keywords is not a good solution. As others pointed out adding $Revision$ in a file only affects the specific file, which may not change for a long time.

记住在每次提交都没有意义之前编辑"文件(通过添加或删除空白行).您也可以手动输入修订.

Remembering to "edit" a file (by adding or removing a blank line) before every commit is pointless. You could as well just type the revision by hand.

(我知道)实现此目标的一种好方法是拥有一个自动化的部署过程(这总是一件好事)并使用命令svnversion.这是我的工作:

One good way to do it (that I know of) is to have an automated deployment process (which is always a good thing) and using the command svnversion. Here is what I do:

我需要修订的地方都包括:<?php include 'version.php'; ?>.此"version.php"文件仅具有修订号.此外,它不是存储库的一部分(将被忽略).这是我的创建方式:

Wherever I need the revision I do an include: <?php include 'version.php'; ?>. This "version.php" file only has the revision number. Moreover it is not part of the repository (it set to be ignored). Here is how I create it:

1)在服务器上安装了SVN的项目上,我也将其用于部署.将最新版本获取到服务器上我有一个脚本,该脚本除其他功能外还可以执行以下操作(该脚本在服务器上运行):

1) On projects where SVN is installed on the server, I also use it for deployment. Getting the latest version to the server I have a script that among other things does the following (it runs on the server):

cd /var/www/project
svn update
rm version.php
svnversion > version.php

2)在未安装SVN的项目中,我的部署脚本更加复杂:它在本地创建version.php文件,压缩代码,然后上载和提取

2) On projects where SVN is not installed my deployment script is more complex: it creates the version.php file locally, zips the code, uploads and extracts it

这篇关于如何获得PHP中的Subversion版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆