如何获得PHP中的Subversion版本号?

编程入门 行业动态 更新时间:2024-10-12 05:54:34
本文介绍了如何获得PHP中的Subversion版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想让我的PHP应用程序标有使用的版本号,但我不想使用 CruiseControl 或更新文件并每次上传.我该怎么办?

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版本号?

本文发布于:2023-11-13 11:04:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584187.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本号   如何获得   PHP   Subversion

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!