I recently spent some time trying to build PHP on Windows, I succeeded in the end but it took rather longer than I'd have liked. I normally use the Windows PHP binaries available from snaps.php.net, but in this case I was trying to test whether a proposed patch would fix a Windows specific defect - so I really had to be able to build PHP. I particularly wanted to use a "free" development environment and, as a Windows novice (and life-time *nix user) I hit a lot of simple issues which took a while to solve. I decided to document the steps that I went through in building PHP in the hope that they might be useful to anyone else that would like to build PHP on a Windows system.
Step by step instructions for building PHP6 (and PHP5)
These instructions are intended to cover everything that you need to do to be able to build PHP on a Windows XP system. They may work on other Windows systems, I haven't checked. No prior knowledge is assumed, except how to perform basic operations using the windows command line (eg mkdir, copy) and how to use an editor (eg edit) and no software (other than Windows) is assumed to be installed.
The instructions have been tested with PHP6 and PHP5, the only difference being that any references to ICU can be ignored if you are building PHP5.
Before starting to build anything you will need to download a set of tools from Microsoft. This can take some time, for example it took me 45 minutes to install the build tools whilst in the office working with a high speed ethernet connection. Working at home with my own broadband connection it took me 4.5 hours to do the same thing. I don't recommend a dial up connection if you can possibly avoid it. The build tools will use approximately 500MB of disk space.
Visual C++ 2005 Express Edition compiler
- Get the Visual C++ 2005 Express Edition compiler from here
- Check that you have the right operating system and processor to be able to use the compiler.
- Click download and then run, or save to disk and then run if you prefer.
- Read and accept the licence and all default settings.
- The compiler will be installed here: C:\Program Files\Microsoft Visual Studio 8\
- At the end you will be asked to register - this takes about 5 minutes, if you don't do it something will keep nagging you.
Windows Server 2003 SP1 PLatform SDK
- Get the Windows Server 2003 SP1 Platform SDK, here.
- There are three options, I chose PSDK-x86.exe as I'm running a 32 bit Windows system. The other two are for amd64 and ia64 systems.
- Click download and then run, or save to disk and then run if you prefer.
- Read and accept the license, then click through the next screens.
- Select "typical" install.
- The code will be installed in: C:\Program Files\Microsoft Platform SDK\
- This is a long installation - 20 minutes on my office connection, 2 hours from home.
Note: There is a more recent version of the SDK that I didn't find until after I'd used the one linked above. The newer version can be found here. I haven't tried it yet so can't say whether it works with these instructions.
The .NET Framework 2.0 SDK
- Get the .NET Framework 2.0 SDK from here. Careful - it takes a couple of minutes to start up and can put the installation window behind the one you are working in.
- Click run, then read and accept the license.
- On the installation options screen just select the Tools and Debugger - you won't need samples or doc.
- Take default installation folder (will be put under the same directory as the Visual C++).
- This is a long download - two hours on my home connection.
A utility to extract tar files on Windows
There are a number of these - I used this and it worked fine. I just downloaded it and followed the installation instructions
Getting PHP and its pre-reqs.
First decide what directory structure you want for your build environment, I use e:\zoe\BUILDS so everywhere I refer to that directory you will need to replace it with whatever you have decided to call your build directory.
I found that the easiest way to extract .zip files on Windows was to open them with Explorer and select "extract all files".
At the end of this section the sub-directory structure should look like this:
| |-winbld32 |e:\zoe\BUILDS - |-bindlib | |-icu | |-php6.0YYYYMMDDHHmm (or php5.0YYYYMMDDHHmm if you are building PHP5) |
- Get PHP - I used the PHP snaps site and downloaded the tar.gz file. I copied it to my e:\zoe\BUILDS directory and used the tar utility (step 1) to extract the contents into e:\zoe\BUILDS\php6.0-YYYYMMDDHHmm
Customising the build environment
Before we can build anything, a little customisation is required to make Visual Studio Express work nicely with the SDK and to tell the build tools where to find the libraries that PHP needs to build. For reference, flex and bison are part of win32build directory and ICU is in the ICU directory. If you are building PHP5 you won't need ICU of course.
- Add paths to the vsvars32.bat file
In directory C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\ edit vsvars32.bat to include references to the Platform SDK in PATH, INCLUDE and LIB.
The relevant lines in my copy look like this:
@set PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;C:\Program Files\Microsoft Platform SDK\Bin;%PATH%@set INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;c:\Program Files\Microsoft Platform SDK\Include;%INCLUDE%@set LIB=C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;c:\Program Files\Microsoft Platform SDK\Lib;%LIB%
- Changes to environment variables.
- Start->Control panel->System->Advanced->Environment variables
- Edit (or add) "path" to add e:\zoe\BUILDS\icu\bin;e:\zoe\BUILDS\win32build\bin
- Edit (or add) "include" to add e:\zoe\BUILDS\icu\include;e:\zoe\BUILDS\win32build\include
- Edit (or add) "lib" to add e:\zoe\BUILDS\icu\lib;e:\zoe\BUILDS\win32build\lib
These changes won't take effect in any windows that you currently have open - you will need to close them and re-open.
Finally - building PHP
- Start up the build environment
- Start -> Visual C++ 2005 Express Edition -> Visual Studio Tools -> Visual Studio 2005 Command Prompt.
- Building resolv.lib.
- In the Visual Studio window, cd e:\zoe\BUILDS\bindlib
- vcexpress (to start the GUI)
- File - > Open -> Project/Solution -> bindlib.dsp
- You'll get a warning about needing to convert bindlib.dsp to the current format. At "Convert and Open", click "yes".
- Now click on Project->Properties->Configuration properties->C/C++/General
- At the top, click "configuration manager" then select "release" and Win32" as the active configurations
- Under additional Include Directories, add (after the dot) ;c:\Program Files\Microsoft Platform SDK\Include and then click OK (this tells it where to find Winsock.h)
- Finally - click on Build and select Build bindlib.
Assuming the the build is successful you can close the GUI - you should find a sub-directory in bindlib called Release. Copy the file resolv.lib from there to e:\zoe\BUILDS\win32build\lib, overwriting the one that's already there.
- Building PHP
- From within your VS C++ window, change directory to the place that you extracted the PHP source
- At the command line, type:
- cscript /nologo configure.js "--with-extra-libs=e:\zoe\BUILDS\icu" "--with-extra-includes=e:\zoe\BUILDS\icu\include" "--without-s
implexml" "--enable-prefix=e:\php6" "--disable-zlib" "--disable-odbc" "--disable-cgi" "--enable-cli" "--without-iconv" "--without-
- nmake install
- Run a test to make sure that the build succeeded
- Create a file called test.php with the following contents <?php phpinfo() ?>
- At the command line, type "e:\php6\php.exe test.php"
Elizabeth Smith Tutorial
The PHP manual
Guillaume Rossolini has translated this into French - see here: here
Guillaume has also tried the newer version of the Microsoft Platform SDK and has confirmed that it works too. The only difference is that the installation folder is: C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2.
Merci beaucoup Guillaume!!
| Added by Z. Slattery , last edited by Z. Slattery on Jun 25, 2007 (view change)
"Going to Chicago; sorry but I can't take you"
Next week I'll be speaking about SCA for PHP at the php|tek 2007
conference in Chicago. We just published our 1.2 release
, which supports a whole load of new SCA bindings (rest-rpc, xml-rpc ..) that have been in beta for a while, so I shall be demonstrating some of those.
I'm told that the conference sold out a while back, but if you are going, do say hello. I'll be wearing my phpwomen
T-shirt, thanks to Elizabeth N and Ligaya!
Caroline Maynard[Read More
I recently returned from the PHP Quebec Conference
where I gave a presentation on the Service Component Architecture (SCA)
. The slides can be found here
. We've been making quite a bit of progress in adding protocol support so I was able to demonstrate bindings for json-rpc
, all of which are available now. Because the conference sessions are 75 minutes long, I was also able to slip in a couple of demos of prototypes for Atom
syndication as well as a custom binding for the eBay soap API
This was the second PHP Quebec conference I have attended, and I thoroughly enjoyed it. The folks of the PHP Quebec Association
do an excellent job, filling three days with some great material from the likes of Rasmus Lerdorf
, Chris Shiflett
, Ilia Alshanetsky
, Rob Richards
, John Coggeshall
, Marcus Börger
, and many more. They also lay on some great entertainment in the evenings. Check out the photo
Cal put up on DevZone
and you'll get an idea of what I mean :-) .Graham Charters
Last week I attended the second UK PHP Conference in London. The organisers had clearly listened to the comments after the first conference, and this year's event was even better. It's the only event of its kind in the UK, and deservedly popular, with a large lecture theatre completely packed.
Like last year, the conference was a one-day, one-track event, and good value for money at £50. It kicked off with Cal Evans, the editor of the Zend dev zone, presenting "My First Mash-Up", getting down with the code to walk us through various ways of tracking a UPS parcel on GoogleMaps with a traditional server-side model and an AJAX model.
Next up was Simon Laws talking about SCA for PHP. Obviously I'm biased but I thought this went really well. Despite being a big lecture theatre, there were a lot of good questions raised throughout the talk, particularly from people who hadn't seen annotations used for dependency injection before: "are annotations bad for performance", "does it work asynchonously", and so on.
After lunch was Kevlin Henney on "Objects of Desire", a talk only loosely about PHP, and one of the highlights. Kevlin is an independent consultant and trainer, specialising in programming languages, OO design, agile development process, patterns and software architecture. He is widely published, but I hadn't heard him speak before. He turned out to be a witty and entertaining speaker, with a lot of wisdom to impart, and deserved the ovation he received.
The big name speaker came next, Rasmus Lerdorf on "Fast and Rich Web Applications with PHP 5". I'd seen Rasmus give a similar talk a couple of times, so there was not much new content for me, but watching him walk through the process of improving the throughput of a simple site one hundred-fold was as impressive as ever, and many of the audience said this was their highlight. Rasmus also got some good questions which were answered .. frankly!
The final wild card was Bill Gaver, a professor of design at Goldsmiths College on "Designing for the Curious Home". Bill and his team go way beyond conventional design issues, resarching some crazy technology ideas, for example wiring up a family home to try and detect the "mood" and then print a daily "horoscope". The one I'd like in my home was the "drift table", which has a viewing window that allows you to float over satellite views of the planet, rather like being in a hot air balloon. Bill says "through these examples, I suggest that computation can go beyond supporting problem solving, consumption and entertainment to enhance a far more varied and subtle range of domestic activities and values". I did notice some muttering around me about the relevance of this talk to the conference, but for me it was much more memorable than many a technical talk.
I had previously whinged to Marcus Baker that it was maybe a bit questionable to select the speakers without a public cfp, but I changed my mind after I'd enjoyed the sessions so much. The personal selection of speakers gave us a more stimulating selection that a committee would have come up with. It could be a new model for computing conferences, akin to the annual Meltdown festival at the South Bank where individual curators (John Peel, Nick Cave, Morrissey, David Bowie, this year Jarvis Cocker) preside over a quirky and personal selection of performances.
After the conference lots of attendees decamped to LivingSpace
, where much beer was consumed, and I was happy to meet a small UK contingent of PHP Women
. The conversation alternated wildly between PHP-related subjects and knitting and crochet. My male colleagues are always complaining about me expecting them to take part in two discussions simultaneously, so I revelled in this. I did have to go through a bit of a post-feminist reevaluation to get to grips with the interest of young women in handicrafts, a subject which I had personally cast off many years ago, but once I'd seized on the key role of the Jacquard loom
in the history of computing as a rationale, my surprise dissolved. I wonder if the UK PHP Conference team would accept a paper on "Babbage and Knitting" as the wacky topic for the 2008 conference? We thought there were about fourteen women at the conference, of 235 attendees. Someone captured us
on Flickr. Later at dinner it was nice to meet Steph Fox in person for the first time, too.
Some other people's photos from the conference are here
. It seems Rasmus had a lot of people throw an arm around him and expect him to smile for the camera :-).
A shameless bit of self-promotion here: I am pleased to say that my Service Component Architecture for PHP article was published in International PHP Magazine this week. It is more or less the same structure and same material as the presentation I gave at Frankfurt, since I wrote them one after another. It is nice to have the words written down, though. Sadly, I was lazy about submitting a photo, so I appear in the guise of International Man of Mystery:
The same issue has an article by colleagues of mine, Graeme Johnson and Zoe Slattery, in which they describe the outcome of a fairly radical experiment. Poor fools, they set out to make a PHP engine using technology already to hand (bits of the Java Virtual Machine, a bit from IBM Research) but absolutely not using the existing engine itself. And this is the hard bit: they wanted to be able still to host the PHP extensions, unchanged. The difficult thing, if I have understood the article correctly, is that the extensions often have quite deep dependencies on the internals of the engine: they depend heavily on macros which in turn expect to know where to find various fields in various structures. This surely must hold back the evolution of engine and extensions since no one can move without breaking something. In the Java world the equivalent interface (JNI = Java Native Interface) manages to keep all the details hidden behind a few opaque handles. Quite an interesting experiment, and an unusual perspective on the PHP engine, I thought.
Matthew Peters[Read More]
We've just made our first release of SCA on the PECL repository. The code has been added into what was the SDO project and which has now been imaginatively renamed to SCA_SDO (you won't believe how much thought went into that...). The main features of this release are:
- inclusion of the Service Component Architecture (SCA) component
- new PEAR packaging to install SCA and SDO as peer directories (PEAR/SCA and PEAR/SDO)
- update to Apache Tuscany C++ SDO revision level 478193
- new function in SDO_DAS_Relational to support multiple root data objects
- new function in SDO_DAS_XML to support CDATA sections (not yet complete)
- fixes for bugs #9287, #9289, #9339
Unfortunately, we were not able to include the json-rpc binding which was demonstrated at the recent Zend and International PHP Conferences. We hope to be able to include this support soon. It's nice to see some positive comments from people who attended those conference presentations. Greg Whitescarver said, "I’m very glad to say that SCA makes exposing services (especially web services) ridiculously easy", and a review on Developpez.com found SCA "...somewhat strange but nevertheless excellent!" (at least that's the Bablefish translation ;-) ).
If you'd like more information on SCA/SDO, please visit the project's community page.
Finally, I'd like to thank Pierre for his help in renaming the SDO project to SCA_SDO, and preserving the old SDO links in the process. Thanks Pierre!Graham Charters
I went to the International PHP 2006 conference in Frankfurt this week and gave a presentation on "Service Component Architecture for PHP". I have uploaded my slides to this blog but have had to split them into two parts, since the PDFs are otherwise too large to upload. I split them into the beginning and end and a block of 10 slides from the middle
I went into Frankfurt for a few hours on the Sunday afternoon. I expected it to be full of skyscrapers, but I was very very wrong; it has instead a pleasant city centre ringed with a few thrilling skyscrapers in the distance. I put a few of my photos up on Flickr.I was struck once again by the contrast between English and German cities: in Germany the public spaces are so much better cared for and more pleasant than they are in England.
The team that ran the conference did a splendid job, as did the hotel itself. I had not realised what an ordered little world I ws living in until I got to Frankfurt airport on a busy Wednesday evening and had to tussle with the real world.
Graham also gave a presentation on SCA for PHP at the Zend conference last week. Once again, despite presenting on the same topic, our presentations are quite different. He does architecture really well; I like to get grubby with hello world in the debugger.
I enjoyed every talk I went to at the conference. I especially enjoy hearing people who know their subject forwards and backwards and who probably wrote the code too, even if I may never need to use what they are talking about, so most of all I enjoyed Tim Bray's talk and the talks by Derick Rethans and Sara Golemon.
Matthew PetersRead More]
I got back from the Zend Conference a few days ago and thought it worth a mention (the conference, not my returning!). I got to attend quite a few session. Rob Richards gave an excellent XML and Web service tutorial. The Amazon and Google presentations were also very interesting. I particularly enjoyed Adam Trachtenberg's pitch on eBay and how to build a business using their API. The example he used was, "Dude, Where's My Used Car" (http://www.dudewheresmyusedcar.com/), a site that he wrote for fun, which mashes eBay Motor listings and Google maps. I'd like to give this a try with SCA, to see whether, a) it works! and b) whether it's any easier. Look out for http://www.excusemesirbutcouldyoupleasetellmewheremyusedmotorvehicleis.co.uk (the thoroughly British subsidiary ;-) ).
Of the main sessions, I found Chris Anderson's Long Tail pitch very interesting and I'm looking forward to reading his book. As ever, Robert "r0ml" Lefkowitz gave an entertaining and thought provoking pitch comparing the evolution of language and literacy over the centuries to the evolution of programming languages and programming literacy. Using this analogy, it appears programming is currently somewhere around the 10th century and programmers are the equivalent of scribes; being paid to read and write for someone else. Another nugget which I believe was attributed to Donald E Knuth's Literate Programming, was the idea of writing programs for humans (the fact that it runs on a computer is incidental). This is something I think we should all do to ensure what we create can be maintained, embraced and furthered by others.
All in all a very good conference, very well organized. A big pat on the back goes to the Zend folks...Graham Charters
Yesterday, I presented and demonstrated SCA for PHP at the Zend/PHP Conference and Expo 2006. You can download the slides here. The session was well attended and I got some good questions at the end. A few people came up asking for the samples I demonstrated (showed how one line of code could be modified to switch from providing a soap/http service to a json-rpc service - I think it's cool, but then I would :-D ).
We are in the process of moving the SCA code into PECL. It will appear in the recently renamed SDO project, which is now called SCA_SDO. I'll put the samples in as part of the move into PECL and blog once this is completed.
I'll blog more about the Zend Conference when I get back...Graham Charters
Service Component Architecture v0.1.0 (alpha) released
We've just made the first release of the Service Component Architecture (SCA) for PHP prototype available.SCA allows you to turn PHP classes into Web services by adding a few simple phpDocumentor-style annotations.SCA will automatically generate WSDL for these services when required. SCA also uses the same annotations technique to allow PHP classes to declare dependencies on other Web services or PHP classes.At runtime it will then 'inject' proxies for these dependencies, which can then be used to call the Web services or classes
Documentation, download package and samples can be found here.A very short whitepaper, which goes through the main concepts of SCA is also available. Our goal is to make this properly open source in the next few weeks, so people can report bugs, submit patches and contribute.We have a phpsoa Google Group where people can discuss SCA and its 'sister' project, SDO.
If you get the chance to give SCA a try, and you have comments/feedback, good or bad, we'd love to hear from you. You can contact us via the Google Group, or via the email addresses for the maintainers of the SDO project.
We recently shipped version 1.0.3 of SDO for PHP
. This was the first version to ship with the C++ SDO library from the Apache Tuscany
open source project - in this case the Milestone 1 release, which was their first packaged version. Currently it's bundled with the SDO for PHP libraries, but as it becomes more stable, we should be able to use Tuscany as an external library too.
Apache Tuscany has both C++ and Java implementations of the SCA specification, as well as SDO. There's a growing community developing lots of exciting new stuff, who post news to http://apache-tuscany.blogspot.com/.
Caroline Maynard[Read More]