Skip to content

Commit 18c0671

Browse files
committed
Prepare for PHP-8.5
1 parent 40f59b4 commit 18c0671

File tree

125 files changed

+7
-9972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+7
-9972
lines changed

.github/workflows/check-cmake.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Run code style checks
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [PHP-8.4]
66
pull_request:
7-
branches: [master]
7+
branches: [PHP-8.4]
88

99
jobs:
1010
check:

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ name: CI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [PHP-8.4]
66
paths-ignore:
77
- 'docs/**'
88
- '.editorconfig'
99
- '.gitignore'
1010
- 'README.md'
1111
pull_request:
12-
branches: [master]
12+
branches: [PHP-8.4]
1313
paths-ignore:
1414
- 'docs/**'
1515
- '.editorconfig'

README.md

Lines changed: 3 additions & 266 deletions
Original file line numberDiff line numberDiff line change
@@ -6,269 +6,6 @@
66
[![GNU](https://img.shields.io/badge/-GNU-A42E2B?logo=gnu&labelColor=17181B)](https://www.gnu.org/)
77
[![Ninja](https://img.shields.io/badge/%F0%9F%A5%B7-Ninja%20build-DD6620?labelColor=17181B)](https://ninja-build.org/)
88

9-
This repository delves into the core of the PHP build system, elucidating the
10-
intricacies of how to build PHP with CMake.
11-
12-
![ElePHPant](docs/images/elephpant.jpg)
13-
14-
## Quick usage - TL;DR
15-
16-
### Step 1 - Install prerequisites
17-
18-
```sh
19-
# Prerequisites for Debian-based distributions:
20-
sudo apt install cmake gcc g++ bison libxml2-dev libsqlite3-dev
21-
22-
# Prerequisites for Fedora-based distributions:
23-
sudo dnf install cmake gcc gcc-c++ bison libxml2-devel sqlite-devel
24-
```
25-
26-
<details>
27-
<summary>Click here for more platforms</summary>
28-
29-
```sh
30-
# Prerequisites for macOS:
31-
xcode-select --install # XCode command line tools
32-
brew install cmake bison # See https://brew.sh how to install Homebrew
33-
34-
# Prerequisites for Alpine Linux:
35-
sudo apk add --no-cache cmake make gcc g++ bison libxml2-dev sqlite-dev
36-
37-
# Prerequisites for BSD-based systems:
38-
sudo pkg install cmake bison libxml2 sqlite3
39-
40-
# Prerequisites for Haiku:
41-
pkgman install cmake bison libxml2_devel sqlite_devel
42-
43-
# Prerequisites for Solaris/illumos-based systems:
44-
sudo pkg install cmake bison libxml2 sqlite-3
45-
```
46-
</details>
47-
48-
### Step 2 - Clone this repository
49-
50-
```sh
51-
git clone https://github.com/petk/php-build-system
52-
53-
cd php-build-system
54-
```
55-
56-
### Step 3 - Download PHP and add CMake files
57-
58-
```sh
59-
cmake -P bin/php.cmake
60-
```
61-
62-
### Step 4 - Generate build system to a build directory
63-
64-
```sh
65-
cmake -S php-8.4-dev -B php-build
66-
```
67-
68-
### Step 5 - Build PHP in parallel
69-
70-
```sh
71-
cmake --build php-build -j
72-
```
73-
74-
After build is complete, you should have a PHP binary that can be run on the
75-
command line:
76-
77-
```sh
78-
./php-build/sapi/cli/php -v
79-
```
80-
81-
## Introduction
82-
83-
PHP developers typically opt for convenient methods to set up PHP on their
84-
machines, such as utilizing prebuilt Linux packages available in their Linux
85-
distribution repositories, deploying Docker images, or relying on user-friendly
86-
stacks that bundle PHP, its extensions, web server, and database into a unified
87-
installation package.
88-
89-
```sh
90-
# Debian-based distributions:
91-
sudo apt install php...
92-
93-
# Fedora-based distributions:
94-
sudo dnf install php...
95-
```
96-
97-
In contrast, the practice of building PHP from source code is primarily reserved
98-
for specific purposes, such as PHP source code development or extensive
99-
customization of PHP configurations on a particular system. This approach is
100-
less commonly employed by everyday PHP developers due to its intricate and
101-
time-consuming nature.
102-
103-
In the realm of software development, a build system is a collection of tools
104-
and files that automate the process of compiling, linking, and assembling the
105-
project's source code into its final form, ready to be executed. It helps
106-
developers with repetitive tasks and ensures consistency and correctness in the
107-
build process for various platforms and hardware out there.
108-
109-
A key function of a build system in the context of C/C++ software development is
110-
to establish a structured framework that guides how code should be written.
111-
Beyond its primary role of compiling source files into executable programs, the
112-
build system plays a pivotal educational role, imparting best practices and
113-
coding standards to developers. By enforcing consistency and adherence to coding
114-
conventions, it fosters the creation of high-quality code, ultimately enhancing
115-
software maintainability and reliability.
116-
117-
Additionally, the build system aims to enable developers to work efficiently by
118-
abstracting away system-specific details, allowing them to focus on the logic
119-
and usability of their code. When adding a new source file or making minor
120-
modifications, developers shouldn't have to delve into the inner workings of the
121-
build system, sift through extensive build system documentation or extensively
122-
explore the complexities of the underlying system.
123-
124-
There are numerous well-known build systems available, ranging from the veteran
125-
GNU Autotools and the widely adopted CMake, to the efficient Ninja, versatile
126-
SCons, adaptable Meson, nimble xmake, and even the simplest manual usage of
127-
Make.
128-
129-
## PHP directory structure
130-
131-
To understand the PHP source code better, it would be beneficial to grasp its
132-
directory structure. PHP is developed at the
133-
[php-src GitHub repository](https://github.com/php/php-src).
134-
135-
After cloning the repository:
136-
137-
```sh
138-
git clone https://github.com/php/php-src
139-
cd php-src
140-
```
141-
142-
you end up with a large monolithic repository consisting of C source code files,
143-
PHP tests and other associated files:
144-
145-
```sh
146-
<php-src>/
147-
├─ .git/ # Git configuration and source directory
148-
├─ benchmark/ # Benchmark some common applications in CI
149-
├─ build/ # *nix build system files
150-
├─ docs/ # PHP internals documentation
151-
└─ ext/ # PHP core extensions
152-
└─ bcmath/ # The bcmath PHP extension
153-
├─ libbcmath/ # The bcmath library forked and maintained in php-src
154-
├─ tests/ # *.phpt test files for extension
155-
├─ bcmath.stub.php # A stub file for the bcmath extension functions
156-
└─ ...
157-
└─ curl/ # The curl PHP extension
158-
├─ sync-constants.php # The curl symbols checker
159-
└─ ...
160-
└─ date/ # The date/time PHP extension
161-
└─ lib/ # Bundled datetime library https://github.com/derickr/timelib
162-
└─ ...
163-
└─ ...
164-
├─ dl_test/ # Extension for testing dl()
165-
└─ dom/
166-
├─ lexbor/ # https://github.com/lexbor/lexbor
167-
└─ ...
168-
└─ ffi/ # The FFI PHP extension
169-
├─ ffi_parser.c # Generated by https://github.com/dstogov/llk
170-
└─ ...
171-
└─ fileinfo/ # The fileinfo PHP extension
172-
├─ libmagic/ # Modified libmagic https://github.com/file/file
173-
├─ data_file.c # Generated by `ext/fileinfo/create_data_file.php`
174-
├─ libmagic.patch # Modifications patch from upstream libmagic
175-
├─ magicdata.patch # Modifications patch from upstream libmagic
176-
└─ ...
177-
└─ gd/ # The GD PHP extension
178-
├─ libgd/ # Bundled and modified GD library https://github.com/libgd/libgd
179-
└─ ...
180-
└─ mbstring/ # The Multibyte string PHP extension
181-
├─ libmbfl/ # Forked and maintained in php-src
182-
├─ unicode_data.h # Generated by `ext/mbstring/ucgendat/ucgendat.php`
183-
└─ ...
184-
└─ opcache/ # The OPcache PHP extension
185-
└─ jit/ # OPcache Jit
186-
└─ ir/ # Bundled part of IR framework https://github.com/dstogov/ir
187-
└─ dynasm/ # DynASM encoding engine
188-
├─ minilua.c # Customized Lua scripting language to build LuaJIT
189-
└─ ...
190-
├─ gen_ir_fold_hash # IR folding engine generator created at build
191-
├─ ir_emit_<arch>.h # IR folding engine rules generated by minilua
192-
├─ minilua # Executable tool created at build
193-
└─ ...
194-
└─ pcre/ # The PCRE PHP extension
195-
├─ pcre2lib/ # https://www.pcre.org/
196-
└─ ...
197-
├─ skeleton/ # Skeleton for new extensions using `ext/ext_skel.php`
198-
└─ standard/ # Always enabled core extension
199-
└─ html_tables/
200-
├─ mappings/ # https://www.unicode.org/Public/MAPPINGS/
201-
└─ ...
202-
├─ credits_ext.h # Generated by `scripts/dev/credits`
203-
├─ credits_sapi.h # Generated by `scripts/dev/credits`
204-
├─ html_tables.h # Generated by `ext/standard/html_tables/html_table_gen.php`
205-
└─ ...
206-
└─ tokenizer/ # The tokenizer PHP extension
207-
├─ tokenizer_data.c # Generated by `ext/tokenizer/tokenizer_data_gen.php`
208-
├─ tokenizer_data_stub.php # Generated by `ext/tokenizer/tokenizer_data_gen.php`
209-
└─ ...
210-
└─ zend_test # For testing internal APIs. Not needed for regular builds
211-
└─ ...
212-
└─ zip/ # Bundled https://github.com/pierrejoye/php_zip
213-
└─ ...
214-
├─ ...
215-
└─ ext_skel.php # Helper script that creates a new PHP extension
216-
└─ main/ # Binding that ties extensions, SAPIs, Zend engine and TSRM together
217-
├─ streams/ # Streams layer subsystem
218-
└─ ...
219-
├─ modules/ # Shared libraries, created when building PHP
220-
├─ pear/ # PEAR installation
221-
└─ sapi/ # PHP SAPI (Server API) modules
222-
└─ cli/ # Command-line PHP SAPI module
223-
├─ mime_type_map.h # Generated by `sapi/cli/generate_mime_type_map.php`
224-
└─ ...
225-
└─ ...
226-
├─ scripts/ # php-config, phpize and internal development scripts
227-
├─ tests/ # Core features tests
228-
├─ TSRM/ # Thread safe resource manager
229-
└─ Zend/ # Zend engine
230-
├─ asm/ # Bundled from src/asm in https://github.com/boostorg/context
231-
├─ Optimizer/ # For faster PHP execution through opcode caching and optimization
232-
├─ tests/ # PHP tests *.phpt files for Zend engine
233-
├─ zend_vm_execute.h # Generated by `Zend/zend_vm_gen.php`
234-
├─ zend_vm_opcodes.c # Generated by `Zend/zend_vm_gen.php`
235-
├─ zend_vm_opcodes.h # Generated by `Zend/zend_vm_gen.php`
236-
└─ ...
237-
├─ win32/ # Windows build files
238-
└─ ...
239-
```
240-
241-
## Why CMake?
242-
243-
At the time of writing, CMake is actively developed, and many developers may
244-
already be familiar with it, making C code more appealing to new contributors.
245-
Numerous IDEs offer excellent CMake integration for C/C++ projects.
246-
247-
CMake shares many similarities with Autotools, which simplifies the learning
248-
curve for those already accustomed to building C code using existing systems.
249-
250-
Notably, CMake features better out-of-the-box support on Windows systems, where
251-
Autotools may encounter issues without additional adaptations and adjustments in
252-
the build process.
253-
254-
Despite Autotools potentially seeming complex and arcane to new developers,
255-
unfamiliar with it, it remains a robust and solid build system option for C/C++
256-
projects on \*nix systems. Many large open-source projects use Autotools, and
257-
some even incorporate it alongside CMake.
258-
259-
## Documentation
260-
261-
* [Introduction to CMake](/docs/cmake-intro.md)
262-
* [CMake-based PHP build system](/docs/cmake.md)
263-
* [Configuration](/docs/configuration.md)
264-
* [Dependencies in C/C++ projects](/docs/dependencies.md)
265-
* [CMake code style](/docs/cmake-code-style.md)
266-
* [Autotools-based PHP build system](/docs/autotools.md)
267-
* [Windows build system for PHP](/docs/windows.md)
268-
* [PHP native and CMake-based build system differences](/docs/differences.md)
269-
* [PHP embed SAPI module](/docs/embed.md)
270-
* [PHP installation](/docs/php-installation.md)
271-
* [Cross-compiling](/docs/cross-compiling.md)
272-
* [PHP build system evolution](/docs/evolution.md)
273-
* [Introduction to C](/docs/c.md)
274-
* [Frequently asked questions](/docs/faq.md)
9+
> [!IMPORTANT]
10+
> You are browsing the `PHP-8.4` branch of this repository. For the latest
11+
> sources and documentation checkout the `master` branch.

docs/CONTRIBUTING.md

Lines changed: 0 additions & 65 deletions
This file was deleted.

docs/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)