Setting up PHP build environment on Windows

One of the things I have done many times in the past year is setting up a build environment for PHP on Windows. I have been using a simple script to do this which I am releasing today with this blog. Here is the zip file contains the script winbuild.bat along with essential tools (wget and unzip) which the script requires. Before you run winbuild.bat, make sure Visual Studio (or VC9 expression edition) and TortoiseSVN are installed on the machine. If you do not have these already installed, you can install VC9 express edition from (select visual studio 2008 express) and TortoiseSVN from Installation of TortoiseSVN might require a reboot. Once machine is ready, download the attached zip, unzip files in a folder, say c:\winbuild, launch visual studio command prompt and then run c:\winbuild\winbuild.bat. By default this script will setup PHP 5.3 build environment in %systemdrive%\php\php_sdk\php_53_dev folder. If you want to choose a different branch and folder location, open winbuild.bat, change variable values on top of the script before running it. This script does the following for setting up the build environment.
·         Create folder structure recommended here.
·         Download and unzip binary tools package.
·         Download and unzip all dependency libraries.
·         Download php source code from
·         Run buildconf and configure commands.
After the script is complete, PHP root will be set to c:\php\php_sdk\php_53_dev\vc9\x86\PHP_5_3. If you change branch/folder locations in the script, this will be different. With the build environment set, you can now run “nmake snap” to build PHP in the PHP root folder. If you want to change configure options, open config.nice.bat (present in PHP root), change the options and run it. Running “nmake snap” will now build PHP using new configure options. Once the build is complete, release binaries will be under the release folder under php root.
Hope this makes setting PHP build environment much simpler. If you run into a bug in winbuild.bat, let me know by leaving a comment. Feature suggestions are also welcome.

Download script here.