Is there a standard place to put the version number in the source code?

I want to have one file where I can check which version is installed. This is a PHP program so you can view files. I was wondering if there was a standard place to host it, since in the Zend Framework or HTMLpurifier I can’t find the version number at all.

I would also like to add it to the Zend Framework and HTMLPurifier if there is no standard location, so I always know which version is installed. The need to update a txt file would be another alternative.

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

+3
source share
4 answers

I found him..

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

const VERSION = '1.7.5';

In HTMLPurifier, it is 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 think for me I will add a version to the configuration file.

+2
source

I would go with a text file option, not in code.

If you do this, as your project progresses, you will be able to update other tools that you may or may not use in your project (for example: phpunderconstrol or a deployment system) to be able to install / update this number without risking these files relating to the real code and potentially cause errors.

, , , - - !

+1

, PHPDoc:

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

const VERSION , PHP 5.3 , . , . , , .

:

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"

, VERSION , libA, libB libC.

+1

, , , . , MySQL HASH, .

PHP , , .

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

By storing version information as ints, you can determine the difference between version numbers.

0
source

Source: https://habr.com/ru/post/1705146/


All Articles