Improving PHP requires a working build environment to test changes, the following section deals with setting up a working build environment.
Your build environment should have an appropriate toolchain that includes a working C compiler, for those not working in Microsoft Windows, you will need a working, compatible autotools installation, and at the very least a shared copy of zlib.
For most *nix like operating systems, some external dependencies may be required to bring a build to completion; if a build fails because of missing headers or libraries, issuing a variant of the following command should resolve those dependencies, allowing the build to continue:
[sudo] yum|apt-get|ports install package[-dev[el]]
For those working in Ubuntu Linux, you can run the following command to automate the installation of dependencies:
sudo apt-get build-dep php5
sudo apt-get build-dep php5-extname
The following table shows what is required for Microsoft Windows users to build PHP:
|PHP||Visual C++||MS SDK||DEPS||PHP SDK|
|5.3||Visual Studio 2008||6.1||x86||here|
|5.4||Visual Studio 2008||6.1||x86||here|
|5.5||Visual Studio 2008||6.1||x86||here|
|5.5||Visual Studio 2012||N/A||x86, x64||here|
Note: If a Windows SDK is required, it is advised to install the SDK before Visual Studio.
Windows users should now download and unzip the PHP SDK to their workspace and execute the following commands in an appropriate Visual Studio Console:
Visual Studio 2008:
setenv /xp /Release /x86
The next step for everyone is to obtain the versioned PHP sources via git:
git clone -b BRANCH https://github.com/php/php-src .
At this point you have a working build environment and the vanilla sources for your chosen branch of PHP, it is a good idea, before you change anything at all, to create a new branch and switch to it, in preparation for your awesome changes to come:
git checkout -b my-awesome-changes
All operating systems now converge on (near as makes no difference) the same solutions for the rest of the build process:
buildconf: generates the configure script for PHP
configure: configures the build of PHP and creates Makefile
make: builds PHP
make test: runs testsuite
make install: installs PHP
For Microsoft Windows operating systems, those commands looks like this:
While for the rest of us, those commands look like this:
The configure script has the ability to customize almost every aspect of PHP, to elicit help at the console pass --help as the only argument to configure
When configure executes, it saves the options passed in to a re-usable config.nice which executes configure when invoked.
Upon successful completion of a build, it is recommended to run the test suite, this will help you to identify regression problems in your work, running the test suite can take a while; go out for a run, or a burger.
It is also possible to run a set (directory) of tests in the following way:
[n]make test TESTS=sapi/cli