|
1 | | -# php-windows-builder |
| 1 | +# PHP and Extensions Pack Build Repository for OSPanel |
2 | 2 |
|
3 | | -This project provides PowerShell packages and GitHub Actions to build PHP and its extensions on Windows. |
| 3 | +This repository provides automated builds of **PHP** and a **PHP Extensions Pack** for the **OSPanel** project. |
4 | 4 |
|
5 | | -## Index |
| 5 | +### Compatibility notice |
| 6 | +All builds are generated for **Windows 10 and newer** with CPU optimizations targeting **SSE4.2** instructions. |
| 7 | +As a result, these binaries are **not compatible** with the official PHP builds distributed via [php.net](https://www.php.net). |
6 | 8 |
|
7 | | -- [GitHub Actions](#github-actions) |
8 | | - - [Build PHP](#build-php) |
9 | | - - [Inputs](#inputs) |
10 | | - - [Example workflow to build PHP](#example-workflow-to-build-php) |
11 | | - - [Build a PHP extension](#build-a-php-extension) |
12 | | - - [Inputs](#inputs-1) |
13 | | - - [Get the job matrix to build a PHP extension](#get-the-job-matrix-to-build-a-php-extension) |
14 | | - - [Inputs](#inputs-2) |
15 | | - - [Outputs](#outputs) |
16 | | - - [PHP Version Support](#php-version-support) |
17 | | - - [Release](#release) |
18 | | - - [Inputs](#inputs-3) |
19 | | - - [Example workflow to build and release an extension](#example-workflow-to-build-and-release-an-extension) |
| 9 | +--- |
20 | 10 |
|
21 | | -- [Local Setup](#local-setup) |
22 | | - - [PHP](#php) |
23 | | - - [PHP Extensions](#php-extensions) |
| 11 | +# Репозиторий сборки PHP и пакета расширений для OSPanel |
24 | 12 |
|
25 | | -- [License](#license) |
| 13 | +Данный репозиторий предназначен для автоматизированной генерации **сборок PHP** и **набора PHP‑расширений** (Extensions Pack), используемых в проекте **OSPanel**. |
26 | 14 |
|
27 | | -## GitHub Actions |
28 | | - |
29 | | -### Build PHP |
30 | | - |
31 | | -Build a specific version of PHP, with the required architecture and thread safety. |
32 | | - |
33 | | -```yaml |
34 | | -- name: Build PHP |
35 | | - uses: php/php-windows-builder/php@v1 |
36 | | - with: |
37 | | - php-version: '8.4.11' |
38 | | - arch: x64 |
39 | | - ts: nts |
40 | | -``` |
41 | | -
|
42 | | -#### Inputs |
43 | | -
|
44 | | -- `php-version` (required) - The PHP version to build. It supports values in major.minor.patch format, e.g. 7.4.25, 8.0.12, etc., or `master` for the master branch of `php-src`. |
45 | | -- `arch` (required) - The architecture to build. It supports values `x64` and `x86`. |
46 | | -- `ts` (required) - The thread safety to build. It supports values `ts` and `nts`. |
47 | | - |
48 | | -#### Example workflow to build PHP |
49 | | - |
50 | | -```yaml |
51 | | -jobs: |
52 | | - php: |
53 | | - strategy: |
54 | | - matrix: |
55 | | - arch: [x64, x86] |
56 | | - ts: [nts, ts] |
57 | | - runs-on: windows-2022 |
58 | | - steps: |
59 | | - - name: Checkout |
60 | | - uses: actions/checkout@v4 |
61 | | -
|
62 | | - - name: Build |
63 | | - uses: php/php-windows-builder/php@v1 |
64 | | - with: |
65 | | - php-version: '8.4.11' |
66 | | - arch: ${{ matrix.arch }} |
67 | | - ts: ${{ matrix.ts }} |
68 | | -``` |
69 | | - |
70 | | -The above workflow will produce the following builds for the PHP version `8.4.1` as artifacts. |
71 | | - |
72 | | -- nts-x64, nts-x64-AVX, ts-x64, nts-x86, ts-x86. |
73 | | -- debug-pack and devel-pack for each the above configurations. |
74 | | -- test pack |
75 | | - |
76 | | -### Build a PHP extension |
77 | | - |
78 | | -Build a specific version of a PHP extension. |
79 | | - |
80 | | -```yaml |
81 | | -- name: Build the extension |
82 | | - uses: php/php-windows-builder/extension@v1 |
83 | | - with: |
84 | | - extension-url: https://github.com/xdebug/xdebug |
85 | | - extension-ref: '3.4.5' |
86 | | - php-version: '8.3' |
87 | | - ts: nts |
88 | | - arch: x64 |
89 | | - args: --with-xdebug |
90 | | - libs: zlib |
91 | | -``` |
92 | | - |
93 | | -#### Inputs |
94 | | - |
95 | | -- `extension-url` (optional) - URL of the extension's git repository, defaults to the current repository. |
96 | | -- `extension-ref` (optional) - The git reference to build the extension, defaults to the GitHub reference that triggered the workflow. |
97 | | -- `php-version` (required) - The PHP versions to build the extension for. |
98 | | -- `arch` (required) - The architecture to build the extension for. |
99 | | -- `ts` (required) - The thread safety to build the extension for. |
100 | | -- `args` (optional) - Additional arguments to pass to the `configure` script. |
101 | | -- `libs` (optional) - Libraries required for the extension. |
102 | | -- `build-directory` (optional) - The directory to build the extension in, defaults to the user's temporary directory. |
103 | | -- `run-tests` (optional) - Run the extension tests. Defaults to `true`. |
104 | | -- `test-runner` (optional) - The test runner to use. Defaults to `run-tests.php`. |
105 | | -- `test-runner-args` (optional) - Arguments to pass to the test runner. |
106 | | -- `test-opcache-mode` (optional) - Run tests with opcache `on`, `off` or `both`. Defaults to `off`. |
107 | | -- `test-workers` (optional) - The number of workers to use when running tests. Defaults to `8`. |
108 | | -- `auth-token` (optional) - Authentication token to use in case the extension is hosted on a private repository. |
109 | | - |
110 | | -Instead of having to configure all the inputs for the extension action, you can use the `extension-matrix` action to get the matrix of jobs with different input configurations. |
111 | | - |
112 | | -### Get the job matrix to build a PHP extension |
113 | | - |
114 | | -```yaml |
115 | | -jobs: |
116 | | - get-extension-matrix: |
117 | | - runs-on: ubuntu-latest |
118 | | - steps: |
119 | | - - name: Checkout |
120 | | - uses: actions/checkout@v4 |
121 | | - - name: Get the extension matrix |
122 | | - id: extension-matrix |
123 | | - uses: php/php-windows-builder/extension-matrix@v1 |
124 | | - with: |
125 | | - extension-url: https://github.com/xdebug/xdebug |
126 | | - extension-ref: '3.4.5' |
127 | | - php-version-list: '8.2, 8.3' |
128 | | - arch-list: 'x64, x86' |
129 | | - ts-list: 'nts, ts' |
130 | | -``` |
131 | | - |
132 | | -#### Inputs |
133 | | - |
134 | | -- `extension-url` (optional) - URL of the extension's git repository, defaults to the current repository. |
135 | | -- `extension-ref` (optional) - The git reference to build the extension, defaults to the GitHub reference that triggered the workflow. |
136 | | -- `php-version-list` (optional) - The PHP versions to build the extension for. Defaults to the PHP versions required in the `composer.json` file. |
137 | | -- `arch-list` (optional) - The architectures to build the extension for. Defaults to `x64, x86`. |
138 | | -- `ts-list` (optional) - The thread safety to build the extension for. Defaults to `nts, ts`. |
139 | | -- `allow-old-php-versions` (optional) - Allow building the extension for older PHP versions. Defaults to `false`. |
140 | | -- `auth-token` (optional) - Authentication token to use in case the extension is hosted on a private repository. |
141 | | - |
142 | | -#### Outputs |
143 | | - |
144 | | -- `matrix` - The matrix of jobs with different input configurations. |
145 | | - |
146 | | -#### PHP Version Support |
147 | | - |
148 | | -By default, the `extension-matrix` action will use the PHP versions defined in the `php-version-list` input. |
149 | | - |
150 | | -If the `php-version-list` input is not provided, it will use the PHP versions required in the `composer.json` file. |
151 | | - |
152 | | -It will also check if a GitHub hosted Windows runner is available with the required Visual Studio version to build the extension for the PHP version or try to install it. To override this for building the extension for older PHP versions, you will have to set the input `allow_old_php_versions` to `true` and add self-hosted Windows runners as specified in the table below. |
153 | | - |
154 | | -| PHP Version | Visual Studio Version | Windows Runner Labels | |
155 | | -|-------------|-----------------------|-----------------------------| |
156 | | -| 7.0 | 2015 (vc14) | windows-2012, self-hosted | |
157 | | -| 7.1 | 2015 (vc14) | windows-2012, self-hosted | |
158 | | -| 7.2 | 2017 (vc15) | windows-2022, github-hosted | |
159 | | -| 7.3 | 2017 (vc15) | windows-2022, github-hosted | |
160 | | -| 7.4 | 2017 (vc15) | windows-2022, github-hosted | |
161 | | -| 8.0 | 2019 (vs16) | windows-2022, github-hosted | |
162 | | -| 8.1 | 2019 (vs16) | windows-2022, github-hosted | |
163 | | -| 8.2 | 2019 (vs16) | windows-2022, github-hosted | |
164 | | -| 8.3 | 2019 (vs16) | windows-2022, github-hosted | |
165 | | -| 8.4 | 2022 (vs17) | windows-2022, github-hosted | |
166 | | -| 8.5 | 2022 (vs17) | windows-2022, github-hosted | |
167 | | -| master | 2022 (vs17) | windows-2022, github-hosted | |
168 | | - |
169 | | -### Release |
170 | | - |
171 | | -Upload the artifacts to a release. |
172 | | - |
173 | | -```yaml |
174 | | -- name: Upload artifact to the release |
175 | | - uses: php/php-windows-builder/release@v1 |
176 | | - with: |
177 | | - release: ${{ github.event.release.tag_name }} |
178 | | - token: ${{ secrets.GITHUB_TOKEN }} |
179 | | -``` |
180 | | - |
181 | | -#### Inputs |
182 | | - |
183 | | -- `release` (required) - The release to upload the artifacts. |
184 | | -- `token` (required) - The GitHub token to authenticate with. |
185 | | - |
186 | | -#### Example workflow to build and release an extension |
187 | | - |
188 | | -```yaml |
189 | | -name: Build extension |
190 | | -on: |
191 | | - # When a new release is created, we can build, and upload the DLLs to it. |
192 | | - release: |
193 | | - types: [created] |
194 | | - # push: # Uncomment this to run on push to a branch |
195 | | - # create: # Uncomment this to run on tag/branch creation |
196 | | - # pull_request: # Uncomment this to run on pull requests |
197 | | -
|
198 | | -# This may be needed to be able to upload the assets to the release |
199 | | -# See: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token |
200 | | -#permissions: |
201 | | -# contents: write |
202 | | -
|
203 | | -jobs: |
204 | | - # This job generates a matrix of PHP versions, architectures, and thread safety options |
205 | | - # This is done by reading the constraints from composer.json or the package.xml file. |
206 | | - # Please refer to https://github.com/php/php-windows-builder#get-the-job-matrix-to-build-a-php-extension |
207 | | - get-extension-matrix: |
208 | | - runs-on: ubuntu-latest |
209 | | - outputs: |
210 | | - matrix: ${{ steps.extension-matrix.outputs.matrix }} |
211 | | - steps: |
212 | | - - name: Checkout |
213 | | - uses: actions/checkout@v5 |
214 | | -
|
215 | | - - name: Get the extension matrix |
216 | | - id: extension-matrix |
217 | | - uses: php/php-windows-builder/extension-matrix@v1 |
218 | | -
|
219 | | - # This job builds the extension on Windows using the matrix generated from the previous job. |
220 | | - build: |
221 | | - needs: get-extension-matrix |
222 | | - runs-on: ${{ matrix.os }} |
223 | | - strategy: |
224 | | - matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}} |
225 | | - steps: |
226 | | - - name: Checkout |
227 | | - uses: actions/checkout@v5 |
228 | | -
|
229 | | - - name: Build the extension |
230 | | - uses: php/php-windows-builder/extension@v1 |
231 | | - with: |
232 | | - # Always specify the php-version, arch, and ts as they are required inputs. |
233 | | - # Please refer to https://github.com/php/php-windows-builder#build-a-php-extension |
234 | | - php-version: ${{ matrix.php-version }} |
235 | | - arch: ${{ matrix.arch }} |
236 | | - ts: ${{ matrix.ts }} |
237 | | - |
238 | | - # This job uploads the built artifacts to the GitHub release. |
239 | | - release: |
240 | | - runs-on: ubuntu-latest |
241 | | - needs: build |
242 | | - if: ${{ github.event_name == 'release' }} |
243 | | - steps: |
244 | | - - name: Upload artifact to the release |
245 | | - uses: php/php-windows-builder/release@v1 |
246 | | - with: |
247 | | - release: ${{ github.event.release.tag_name }} |
248 | | - token: ${{ secrets.GITHUB_TOKEN }} |
249 | | -``` |
250 | | - |
251 | | -For more example workflows, please refer to the [examples](./examples) directory. |
252 | | - |
253 | | -## Local Setup |
254 | | - |
255 | | -### PHP |
256 | | - |
257 | | -To build PHP locally, you can install the `BuildPhp` powershell module from the PowerShell Gallery: |
258 | | - |
259 | | -You'll need at least PowerShell version 5, which is available by default on Windows 10 and later. It is recommended to use PowerShell 7 or later. |
260 | | -If you have an older version, you can install the latest version [following these instructions](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows). |
261 | | - |
262 | | -Open an elevated PowerShell session (Run as Administrator) and run the following command to install the module: |
263 | | - |
264 | | -```powershell |
265 | | -Install-Module -Name BuildPhp -Repository PSGallery -Force |
266 | | -``` |
267 | | - |
268 | | -To install this module for the current user only: |
269 | | - |
270 | | -```powershell |
271 | | -Install-Module -Name BuildPhp -Repository PSGallery -Force -Scope CurrentUser |
272 | | -``` |
273 | | - |
274 | | -Next, make sure you have the required Visual Studio version installed to build the PHP version you want. You can find the required Visual Studio version in the [PHP Version Support table](#php-version-support) above. |
275 | | -If the required Visual Studio version is not installed, for the first time you try to build PHP, the module will try to install the required Visual Studio components automatically. |
276 | | - |
277 | | -Then, you can build PHP by using the `Invoke-PhpBuild` command. |
278 | | -- To build a specific PHP version, you can use the `PhpVersion` input. It supports values in major.minor.patch format, e.g., 7.4.25, 8.0.12, etc., or `master` for the master branch of `php-src`. |
279 | | -- To build a 32-bit or a 64-bit version, you can use the `Arch` input. It supports values `x64` and `x86`. |
280 | | -- To build a thread-safe or non-thread-safe version, you can use the `Ts` input. It supports values `ts` and `nts`. |
281 | | - |
282 | | -```powershell |
283 | | -Invoke-PhpBuild -PhpVersion '8.4.11' -Arch x64 -Ts nts |
284 | | -``` |
285 | | - |
286 | | -To build PHP from a local source, run `Invoke-PhpBuild` from the source directory and omit the `PhpVersion` input. |
287 | | - |
288 | | -```powershell |
289 | | -Invoke-PhpBuild -Arch x64 -Ts nts |
290 | | -``` |
291 | | - |
292 | | -It should produce the PGO optimized builds for the input PHP version and configuration in a directory named `artifacts` in the current directory. |
293 | | - |
294 | | -### PHP Extensions |
295 | | - |
296 | | -To build a PHP extension locally, you can install the `BuildPhpExtension` powershell module from the PowerShell Gallery: |
297 | | -Again, You'll need at least PowerShell version 5, which is available by default on Windows 10 and later. It is recommended to use PowerShell 7 or later. |
298 | | -If you have an older version, you can install the latest version [following these instructions](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows). |
299 | | - |
300 | | -Open an elevated PowerShell session (Run as Administrator) and run the following command to install the module: |
301 | | - |
302 | | -```powershell |
303 | | -Install-Module -Name BuildPhpExtension -Repository PSGallery -Force |
304 | | -``` |
305 | | - |
306 | | -To install this module for the current user only: |
307 | | - |
308 | | -```powershell |
309 | | -Install-Module -Name BuildPhpExtension -Repository PSGallery -Force -Scope CurrentUser |
310 | | -``` |
311 | | - |
312 | | -Next, make sure you have the required Visual Studio version installed to build the PHP extension you want. You can find the required Visual Studio version in the [PHP Version Support table](#php-version-support) above based on the PHP version you are building the PHP extension for. |
313 | | -If the required Visual Studio version is not installed, for the first time you try to build the PHP extension, the module will try to install the required Visual Studio components automatically. |
314 | | - |
315 | | -Then, you can build the PHP extension by using the `Invoke-PhpBuildExtension` command. |
316 | | -- To build a php extension from a git repository, you can use the `ExtensionUrl` input. It supports a git repository URL as value. |
317 | | -- To build a specific version of the extension, you can use the `ExtensionRef` input. It supports a git reference, e.g., a tag or a branch as value. |
318 | | -- To build the extension for a specific PHP version, you can use the `PhpVersion` input. It supports values in major.minor format, e.g., 7.4, 8.0, etc. |
319 | | -- To build the extension for a 32-bit or a 64-bit PHP version, you can use the `Arch` input. It supports values `x64` and `x86`. |
320 | | -- To build the extension for a thread-safe or non-thread-safe PHP version, you can use the `Ts` input. It supports values `ts` and `nts`. |
321 | | -- To specify the libraries required for the extension, you can use the `Libraries` input. It supports a comma-separated list of library names. |
322 | | -- To specify additional arguments to pass to the `configure` script, you can use the `Args` input. It supports a string value. |
323 | | - |
324 | | -```powershell |
325 | | -Invoke-PhpBuildExtension -ExtensionUrl https://github.com/xdebug/xdebug ` |
326 | | - -ExtensionRef 3.4.5 ` |
327 | | - -PhpVersion 8.4 ` |
328 | | - -Arch x64 ` |
329 | | - -Ts nts ` |
330 | | - -Libraries "zlib" ` |
331 | | - -Args "--with-xdebug" |
332 | | -``` |
333 | | - |
334 | | -To build an extension from a local source, run `Invoke-PhpBuildExtension` from the extension’s source directory and omit the `ExtensionUrl` and `ExtensionRef` inputs. |
335 | | - |
336 | | -```powershell |
337 | | -# cd to xdebug source directory, and then run |
338 | | -Invoke-PhpBuildExtension -PhpVersion 8.4 -Arch x64 -Ts nts -Libraries "zlib" -Args "--with-xdebug" |
339 | | -``` |
340 | | - |
341 | | -It should produce the extension builds in a directory named `artifacts` in the current directory. |
342 | | - |
343 | | -## License |
344 | | - |
345 | | -The scripts and documentation in this project are released under the [MIT License](LICENSE) |
| 15 | +### Примечание о совместимости |
| 16 | +Все сборки создаются для **Windows 10 и выше** с применением оптимизаций под инструкции **SSE4.2**. |
| 17 | +По этой причине данные бинарные файлы **не совместимы** с официальными сборками PHP, распространяемыми через [php.net](https://www.php.net). |
0 commit comments