Defining A Version Number

I’m trying to work out the best way to define a version for the application within the Yii way of doing things.

In previous PHP applications before moving to Yii, we just created a version.php file that had an application version and database version defined in it.

Ideally I would like to have the database migration integrated into this so we could do things like take the site down if the database version does not match application version.

What to you use for deploys? as a builder (phing, ant) or just a deploy script. You could possible add it to your main.php as a param so that it can be accessed any where in the system.

We define two config parameters that hold the source version in “protected/config/”. One is the DVS reference, and the other one is human-readable. So from Yii they can be read with Yii::app()->params['version']. Then we could detect if the DB is not synchronized with the source code.

But we don’t do it because DB migration are always automatically applied. We add a git/hg hook so that each update modifies the config file (with the DVCS ref) and applies the migration. The reference is inserted with a one-liner perl -i -pe 's/.../.../' ... but it could be done with a PHP script.