Build and modify the PHP interpreter source code
You can build the engine that interprets and executes PHP code behind web servers. This repository contains the C source code for the PHP interpreter, along with build tools and a test suite. Developers can build this code to create PHP tailored to specific environments, or participate in fixing bugs and proposing new features.
Building PHP from source
To build directly from source without using a finished binary, you need autoconf, bison, and re2c. For a default build, you must also install the libxml2 and libsqlite3 libraries. The documentation lists package installation commands for major operating systems such as Ubuntu, Fedora, and MacOS, making the preparation process easy to follow. Generate the configuration file with ./buildconf, specify options with ./configure, and compile with make. Adding the --enable-debug option is recommended for development builds, while production builds use the default options.
Running the test suite and verifying quality
PHP includes an extensive test suite to verify stability after code changes. After compilation, running the make test command executes the tests automatically, utilizing up to 10 logical processors in parallel by default. To run tests only in a specific directory or adjust the number of parallel jobs, set the TEST_PHP_ARGS or TESTS variables. For example, you can run only specific language feature tests with make TESTS=tests/lang/ test. This testing process is an essential step to ensure that PHP's core features work as intended.
Extension management and contribution procedures
In addition to built-in extensions, PHP allows installing additional features as extensions. Extensions are managed via PIE (PHP Installer for Extensions) or PECL (legacy), which is the standard method for extending PHP's functionality. To contribute to this repository, you must fork it and send a pull request. Adding new features requires going through the RFC (Request for Comments) process to gain approval from the developer community. In contrast, bug fixes can proceed without an RFC, provided you reference the related issue number in the commit message using the GH-NNNNNN format. Contribution guidelines and coding standards are detailed in the repository's documentation.
Pre-build checks and license
Building this repository directly requires an environment with a C compiler and specific system libraries installed. In particular, on Windows, it is common to follow a separate build guide or use official binaries, while on Linux-based systems, resolving dependencies via a package manager is more efficient. PHP is distributed under the Modified BSD License (BSD-3-Clause), allowing free commercial use and modification. However, before deploying PHP built from source to a production environment, you must ensure it passes make test and verify that all necessary extensions are included. Build errors may occur on specific operating systems or hardware configurations, so it is important to carefully follow the requirements in the official documentation.