wow! that was fun.
This is how you do it, using Sara Golemon’s Extending and Embedding PHP as a reference (a fabulous book, by the way).
- create a folder on your c drive, like C:\PHPDEV
- download php 5.2.6 source from a mirror (this is the current php 5 version, time of this post). Save this tar.gz file into C:\PHPDEV. EXTRACT IT THERE.
- download php win32 build extras and save into C:\PHPDEV. EXTRACT IT THERE.
- Get pre-built binary packages for bison.exe and flex.exe. Put those on your desktop, or somewhere AWAY from C:\PHPDEV.
Open both archives and go into their /bin directories. Take flex.exe from the flex archive and bison.exe from the bison archive and put THOSE into C:\PHPDEV.
The next step can get twisted if you don’t have Visual Studio (any version?) installed.
If you don’t have it, try the express editions, or take a look at ishouldbecoding.com article.
Assuming you have Visual Studio 2008, FIRST, open C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat.
The file is about 50 lines long full of @set type statements.
Find the line that starts with
@set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;(goes on)
Change that line to read
@set PATH=C:\PHPDEV;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;(leave the rest exactly as it were)
So all I did there was add C:\PHPDEV; just after the = sign. The reason I did that was so that flex.exe and bison.exe are part of the system path now.
NOW, go to Start->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt.
- switch to C:\PHPDEV\php-5.2.6
- type buildconf.bat
What this does is scan all folders for .w32 files and creates configure.js for you
cscript /nologo configure.js --without-xml --without-wddx --without-simplexml --without-dom --without-libxml --disable-zlib --without-sqlite --disable-odbc --disable-cgi --enable-cli --enable-debug --without-iconv --disable-ipv6
**** COPY PASTE THE ABOVE LINE. ITS LONGER THAN IT LOOKS.
what this does is modify configure.js for you. You can get the same effect I guess by going into configure.js and manually setting things to “yes” and “no”. Why disable all these things? Most of these aren’t included in the bundle you downloaded, so you’d get compile errors like “file not found” if you didn’t disable these.
if you don’t have bison.exe, you’ll get:
ERROR: bison is required
If you don’t have flex.exe, you’ll get
ERROR: flex is required
- switch to c:\PHPDEV\php-5.2.6\Debug_TS
- Type something like
php -r “$x = ‘hello’; echo($x);”
Sara, you are fantastic. The book is rich and explains things very clearly. I had to skim through some of the stuff about php life cycle and php variables, because I was anxious to build it, but there’s tons more to read here :). Seems to be fairly considerate to windows users. Thanks for writing that book, to begin with.