Yii Frequently asked questions

This page lists some frequently encountered questions and issues related to Yii framework (both Yii 1 and Yii2).

How to check Yii version number

Unfortunately, not all versions of Yii has the same standard method of checking the version of script. Here are couple of methods to be used to get that done.

Yii getVersion() function

One method is to go to your /framework folder and edit the yii.php file.

At the end of that file, add this code:

echo Yii::getVersion();

However if you’re running a live site then you should modify the code a little to prevent it from showing the version to the public. Rather output the code in the source of the page which you can check inside html comments in view-source of your webpage. This would then look like this:

echo "<!-- yii-version: " . Yii::getVersion() . " -->";

In Yii 2, run ./yii file in terminal

In Yii 2, you can also view the version output from the yii file in your framework root, when you run it in the terminal. If you’re running a windows based server then you need to run yii.bat file in the same folder. (not tested this method personally, however the getVersion is tested by me on version 1.x of yii). In version 1 of yii, there is file yiic in the same folder, however that’s not tested and confirmed by me yet to be of help in our scenario.

Leave a Reply

Your email address will not be published.