Yii and XAMPP server on Windows

This article explains issues about installing XAMPP server package (Lite version) on Windows OS and configuring it for serving webapps written in Yii. Please note, that XAMPP is available for many more platforms and systems. I write about Windows edition as it was the only one tested by me.

>Info: It is also worth underlining that I'm using XAMPP for years as development environment only. I host my apps in production versions on paid hosting and cannot guarantee that XAMPP has enough security level for running as production server. Especially if you want to use Windows version for this purpose, which is highly NOT advisable! Please, consult its documentation or community about that.

For development purposes the Lite version available here is far enough. Consult documentation to see differences between Lite and Full versions. Please note: Lite version does not contains any mail server and mail() PHP function fails because of that. You need full version of XAMPP, if you plan to test applications with mailing capabilities (for example: e-mailing new password in user management modules or RBAC extensions).


At the beginning it is important to answer why to choose XAMPP among so many server packages available? Well, there are two strong advantages of it. First - it's configuration is so easy, that even a child can do it. It particularly is minimized to unzip archive and run setup batch. Second - XAMPP is extremely portable! Moving it from one directory or drive to another requires only one run of setup_xampp.bat. You can even install it on USB stick and have your private webserver along with your apps go anywhere with you and to be available on any computer, you plug your USB stick to!

As I read other Wiki articles on how many problems people have with installing and configuring other servers or server pack I think it can be more simplier than with XAMPP.

Differences betweens setup version (EXE) and setup-less version (ZIP) are at least questionable (half the size for the first one) and I still can't figure out how do the achieve it? :) But for this tutorial and for advantages of portability we will use ZIP version.

Installing XAMPP

Well... there is actually no installation. Just unzip archive grabbed from ApacheFriends website to a directory of your choice, execute setup_xampp.bat inside unzipped folder once and answer to a few simple questions (including one, if you want to make XAMPP portable - i.e. put on a USB stick).

After that, execute xampp_control.exe to run any webserver component (like Apache, MySQL) you need or to install it as system service. If you pass this step, you can open your browser and point it to localhost to see XAMPP welcome page, which consist of some modules for checking / granting security to your webapps run under this server. If everything is double checked and all issues all solved, you may delete contents of httpd subfolder in you XAMPP directory.

That would be all! :)

Installing Yii

I assume that you've already grabbed zip file containing newest edition of Yii. If you are already familiar with Yii, you may obey demos folder, but it might be wise to run at least once a requirements to see, if your fresh XAMPP installation satisfy all yours and Yii's needs? For this purpose, copy contents of archive to httpd subfolder in you XAMPP directory and go to localhost in your webbrowser.

If everything is fine, you may move Yii outside webaccessible directory, as it is advised in documentation, and update bootstrap index.php file in your webapps to point to correct file. In my situation I put contents of an archive in the same directory as httpd subfolder (i.e. main XAMPP folder) and rename framework directory to yii. Therefore my bootstrap file looks like this:

$yii = dirname(__FILE__).'/../../yii/yii.php';
$config = dirname(__FILE__).'/protected/config/main.php';



This example (XAMPP server) was tested by me on Windows 2000, XP and 7, but I'm pretty sure that it should run without any problems on any modern version of Windows (2000 and up).

>Info: For yiic to work without any problems, you have to go to Computer > Properties > Advanced system settings > Advanced > Environment Variables > System Variables, click on Path and then on Edit and add there a correct path to both php and yii folders in the location, where you installed XAMPP.

If you done everything correctly, you may now start coding with wonderful Yii framework.

Completely off-topic. This is Yii Cookbook article number one hundred! :)