views:

276

answers:

4

I want to have one file where I can check which version is installed. Its a PHP program so you can look into the files. I was thinking if there is a standardized place to put it since in the Zend Framework or the HTMLpurifier I can't find the version number at all.

I would also want to add it to the Zend Framework and HTMLPurifier if there is no standard location so I always know what version is installed. Having to update a txt file would be another alternative..

EDIT: We are thinking of using PHPundercontrol in the very near future but why should it update the Zend Frameworks number? How should it know that I uploaded a new version of it?

+1  A: 

I would go with the text file option rather than in the code.

If you do this, as your project progresses, you can update other tools that you may or may not start to use on your project (eg: phpunderconstrol or a deployment system) to be able to set/update this number without having to risk those files touching real code and potentially causing bugs.

Of course, this all depends on how you see your project progressing and whether you think you will ever use any other tools!

benlumley
I just edited my entry so it adds that stuff
Thomaschaaf
more important for phpundercontrol is probably your own svn release number?
benlumley
to get the ZF release number, if its not provided anywhere in the zf source (there is likely some kind of changelog file that you could parse for it), you could always write an automated script to upgrade the ZF files to latest version and set the version number at this point from the tar filename.
benlumley
A: 

What i do is create a config file that stays with the program wherever i am in it. There i have settings like the MySQL config info and the password HASH and also the version info of the project.

PHP's source code does it this way also, they save the version info like this.

// this is a guess of the var names by me btw
MAJOR_VERSION = 5
MINOR_VERSION = 2
FIX_VERSION = 6

By keeping the version info as ints you can calulcte the difference between version numbers.

Ólafur Waage
but where would I find the version number in frameworks?
Thomaschaaf
+2  A: 

I found it..

in the Zend Framework they have a file called Zend/Version.php -> Zend_Version this file also has the Version number inside of it:

const VERSION = '1.7.5';

In the HTMLPurifier it's located in HTMLPurifier/HTMLPurifier.php

/** Version of HTML Purifier */
public $version = '3.3.0';

/** Constant with version of HTML Purifier */
const VERSION = '3.3.0';

I guess for mine I will add the version into a config file then.

Thomaschaaf
+1  A: 

If you're looking into source files, there is PHPDoc standard:

/**
 * ...
 * @version  1.2.3
 */

The problem with const VERSION is that PHP prior to 5.3 is that there are no namespaces. So it doesn't serve you much when you include various libraries. Even harder to tell you use autoload and can't really be sure of order in which they are included.

e.g:

index.php

include_once "libA.php"
if(needsB)
  include_once "libB.php"
...
print(VERSION)

libB.php

const VERSION='1.2.3'
...
if(needsC)
  include_once "libC.php"

Now you can't be sure which VERSION you print, the one from libA, libB or libC.

vartec