Skip to content

Commit 9de21fa

Browse files
committed
Add local setup section in README
1 parent b725a27 commit 9de21fa

File tree

1 file changed

+115
-13
lines changed

1 file changed

+115
-13
lines changed

README.md

Lines changed: 115 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
# php-windows-builder
22

3-
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.
44

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
630

731
Build a specific version of PHP, with the required architecture and thread safety.
832

@@ -15,13 +39,13 @@ Build a specific version of PHP, with the required architecture and thread safet
1539
ts: nts
1640
```
1741
18-
### Inputs
42+
#### Inputs
1943
2044
- `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`.
2145
- `arch` (required) - The architecture to build. It supports values `x64` and `x86`.
2246
- `ts` (required) - The thread safety to build. It supports values `ts` and `nts`.
2347

24-
### Example workflow to build PHP
48+
#### Example workflow to build PHP
2549

2650
```yaml
2751
jobs:
@@ -49,7 +73,7 @@ The above workflow will produce the following builds for the PHP version `8.4.1`
4973
- debug-pack and devel-pack for each the above configurations.
5074
- test pack
5175

52-
## Build a PHP extension
76+
### Build a PHP extension
5377

5478
Build a specific version of a PHP extension.
5579

@@ -66,7 +90,7 @@ Build a specific version of a PHP extension.
6690
libs: zlib
6791
```
6892

69-
### Inputs
93+
#### Inputs
7094

7195
- `extension-url` (optional) - URL of the extension's git repository, defaults to the current repository.
7296
- `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.
85109

86110
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.
87111

88-
## Get the job matrix to build a PHP extension
112+
### Get the job matrix to build a PHP extension
89113

90114
```yaml
91115
jobs:
@@ -105,7 +129,7 @@ jobs:
105129
ts-list: 'nts, ts'
106130
```
107131

108-
### Inputs
132+
#### Inputs
109133

110134
- `extension-url` (optional) - URL of the extension's git repository, defaults to the current repository.
111135
- `extension-ref` (optional) - The git reference to build the extension, defaults to the GitHub reference that triggered the workflow.
@@ -115,11 +139,11 @@ jobs:
115139
- `allow-old-php-versions` (optional) - Allow building the extension for older PHP versions. Defaults to `false`.
116140
- `auth-token` (optional) - Authentication token to use in case the extension is hosted on a private repository.
117141

118-
### Outputs
142+
#### Outputs
119143

120144
- `matrix` - The matrix of jobs with different input configurations.
121145

122-
### PHP Version Support
146+
#### PHP Version Support
123147

124148
By default, the `extension-matrix` action will use the PHP versions defined in the `php-version-list` input.
125149

@@ -142,7 +166,7 @@ It will also check if a GitHub hosted Windows runner is available with the requi
142166
| 8.5 | 2022 (vs17) | windows-2022, github-hosted |
143167
| master | 2022 (vs17) | windows-2022, github-hosted |
144168

145-
## Release
169+
### Release
146170

147171
Upload the artifacts to a release.
148172

@@ -154,12 +178,12 @@ Upload the artifacts to a release.
154178
token: ${{ secrets.GITHUB_TOKEN }}
155179
```
156180

157-
### Inputs
181+
#### Inputs
158182

159183
- `release` (required) - The release to upload the artifacts.
160184
- `token` (required) - The GitHub token to authenticate with.
161185

162-
### Example workflow to build and release an extension
186+
#### Example workflow to build and release an extension
163187

164188
```yaml
165189
name: Build extension
@@ -211,6 +235,84 @@ jobs:
211235
token: ${{ secrets.GITHUB_TOKEN }}
212236
```
213237

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:
248+
249+
```powershell
250+
Install-Module -Name BuildPhp -Repository PSGallery -Force
251+
```
252+
253+
To install this module for the current user only:
254+
255+
```powershell
256+
Install-Module -Name BuildPhp -Repository PSGallery -Force -Scope CurrentUser
257+
```
258+
259+
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`.
266+
267+
```powershell
268+
Invoke-PhpBuild -Version '8.4.1' -Arch x64 -Ts nts
269+
```
270+
271+
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:
280+
281+
```powershell
282+
Install-Module -Name BuildPhpExtension -Repository PSGallery -Force
283+
```
284+
285+
To install this module for the current user only:
286+
287+
```powershell
288+
Install-Module -Name BuildPhpExtension -Repository PSGallery -Force -Scope CurrentUser
289+
```
290+
291+
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.
303+
304+
```powershell
305+
$env:LIBRARIES = 'zlib'
306+
$env:CONFIGURE_ARGS = '--with-xdebug'
307+
Invoke-PhpBuildExtension -ExtensionUrl https://github.com/xdebug/xdebug `
308+
-ExtensionRef 3.3.2 `
309+
-PhpVersion 8.4 `
310+
-Arch x64 `
311+
-Ts nts
312+
```
313+
314+
It should produce the extension builds in a directory named `artifacts` in the current directory.
315+
214316
## License
215317

216318
The scripts and documentation in this project are released under the [MIT License](LICENSE)

0 commit comments

Comments
 (0)