You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project provides actions to build PHP and its extensions on Windows.
3
+
This project provides PowerShell packages and GitHub Actions to build PHP and its extensions on Windows.
4
4
5
-
## Build PHP
5
+
## Index
6
+
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)
20
+
21
+
-[Local Setup](#local-setup)
22
+
-[PHP](#php)
23
+
-[PHP Extensions](#php-extensions)
24
+
25
+
-[License](#license)
26
+
27
+
## GitHub Actions
28
+
29
+
### Build PHP
6
30
7
31
Build a specific version of PHP, with the required architecture and thread safety.
8
32
@@ -15,13 +39,13 @@ Build a specific version of PHP, with the required architecture and thread safet
15
39
ts: nts
16
40
```
17
41
18
-
### Inputs
42
+
#### Inputs
19
43
20
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`.
21
45
- `arch`(required) - The architecture to build. It supports values `x64` and `x86`.
22
46
- `ts`(required) - The thread safety to build. It supports values `ts` and `nts`.
23
47
24
-
### Example workflow to build PHP
48
+
#### Example workflow to build PHP
25
49
26
50
```yaml
27
51
jobs:
@@ -49,7 +73,7 @@ The above workflow will produce the following builds for the PHP version `8.4.1`
49
73
- debug-pack and devel-pack for each the above configurations.
50
74
- test pack
51
75
52
-
## Build a PHP extension
76
+
### Build a PHP extension
53
77
54
78
Build a specific version of a PHP extension.
55
79
@@ -66,7 +90,7 @@ Build a specific version of a PHP extension.
66
90
libs: zlib
67
91
```
68
92
69
-
### Inputs
93
+
#### Inputs
70
94
71
95
- `extension-url`(optional) - URL of the extension's git repository, defaults to the current repository.
72
96
- `extension-ref`(required) - The git reference to build the extension, defaults to the GitHub reference that triggered the workflow.
@@ -85,7 +109,7 @@ Build a specific version of a PHP extension.
85
109
86
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.
87
111
88
-
## Get the job matrix to build a PHP extension
112
+
### Get the job matrix to build a PHP extension
89
113
90
114
```yaml
91
115
jobs:
@@ -105,7 +129,7 @@ jobs:
105
129
ts-list: 'nts, ts'
106
130
```
107
131
108
-
### Inputs
132
+
#### Inputs
109
133
110
134
- `extension-url`(optional) - URL of the extension's git repository, defaults to the current repository.
111
135
- `extension-ref`(optional) - The git reference to build the extension, defaults to the GitHub reference that triggered the workflow.
@@ -115,11 +139,11 @@ jobs:
115
139
- `allow-old-php-versions`(optional) - Allow building the extension for older PHP versions. Defaults to `false`.
116
140
- `auth-token`(optional) - Authentication token to use in case the extension is hosted on a private repository.
117
141
118
-
### Outputs
142
+
#### Outputs
119
143
120
144
- `matrix`- The matrix of jobs with different input configurations.
121
145
122
-
### PHP Version Support
146
+
#### PHP Version Support
123
147
124
148
By default, the `extension-matrix` action will use the PHP versions defined in the `php-version-list` input.
125
149
@@ -142,7 +166,7 @@ It will also check if a GitHub hosted Windows runner is available with the requi
@@ -154,12 +178,12 @@ Upload the artifacts to a release.
154
178
token: ${{ secrets.GITHUB_TOKEN }}
155
179
```
156
180
157
-
### Inputs
181
+
#### Inputs
158
182
159
183
- `release`(required) - The release to upload the artifacts.
160
184
- `token`(required) - The GitHub token to authenticate with.
161
185
162
-
### Example workflow to build and release an extension
186
+
#### Example workflow to build and release an extension
163
187
164
188
```yaml
165
189
name: Build extension
@@ -211,6 +235,84 @@ jobs:
211
235
token: ${{ secrets.GITHUB_TOKEN }}
212
236
```
213
237
238
+
## Local Setup
239
+
240
+
### PHP
241
+
242
+
To build PHP locally, you can install the `BuildPhp` powershell module from the PowerShell Gallery:
243
+
244
+
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.
245
+
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).
246
+
247
+
Open an elevated PowerShell session (Run as Administrator) and run the following command to install the module:
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.
260
+
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.
261
+
262
+
Then, you can build PHP by using the `Invoke-PhpBuild` command.
263
+
- To build a specific version, use the `Version` 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`.
264
+
- To build a 32-bit or a 64-bit version, use the `Arch` input. It supports values `x64` and `x86`.
265
+
- To build a thread-safe or non-thread-safe version, use the `Ts` input. It supports values `ts` and `nts`.
It should produce the PGO optimized builds for the input PHP version and configuration in a directory named `artifacts` in the current directory.
272
+
273
+
### PHP Extensions
274
+
275
+
To build a PHP extension locally, you can install the `BuildPhpExtension` powershell module from the PowerShell Gallery:
276
+
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.
277
+
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).
278
+
279
+
Open an elevated PowerShell session (Run as Administrator) and run the following command to install the module:
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.
292
+
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.
293
+
294
+
Then, you can build the PHP extension by using the `Invoke-PhpBuildExtension` command.
295
+
- To build a php extension, use the `ExtensionUrl` input. It supports a git repository URL as value.
296
+
- To build a specific version of the extension, use the `ExtensionRef` input. It supports a git reference, e.g., a tag or a branch as value.
297
+
- To build the extension for a specific PHP version, use the `PhpVersion` input. It supports values in major.minor format, e.g., 7.4, 8.0, etc.
298
+
- To build the extension for a 32-bit or a 64-bit version, use the `Arch` input. It supports values `x64` and `x86`.
299
+
- To build the extension for a thread-safe or non-thread-safe version, use the `Ts` input. It supports values `ts` and `nts`.
300
+
301
+
If your extension requires additional libraries, you can set the Libraries environment variable to a list of libraries separated by comma.
302
+
If your extension requires additional arguments to pass to the `configure` script, you can set the `Args` environment variable to the additional arguments.
0 commit comments