Skip to content

Commit 27ff6b4

Browse files
dunglasCopilot
andauthored
docs: contributing on Windows (#2222)
Signed-off-by: Kévin Dunglas <kevin@dunglas.fr> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent db41496 commit 27ff6b4

2 files changed

Lines changed: 80 additions & 13 deletions

File tree

.github/workflows/windows.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ jobs:
217217
"opcache.enable=0`r`nopcache.enable_cli=0" | Out-File php.ini
218218
$env:PHPRC = Get-Location
219219
220-
go test ./...
220+
go test -race ./...
221221
cd caddy
222-
go test ./...
222+
go test -race ./...
223223
working-directory: ${{ github.workspace }}\frankenphp

CONTRIBUTING.md

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The image contains the usual development tools (Go, GDB, Valgrind, Neovim...) an
1717
- additional configuration files: `/etc/frankenphp/php.d/*.ini`
1818
- php extensions: `/usr/lib/frankenphp/modules/`
1919

20-
If your Docker version is lower than 23.0, the build will fail due to dockerignore [pattern issue](https://github.com/moby/moby/pull/42676). Add directories to `.dockerignore`.
20+
If your Docker version is lower than 23.0, the build will fail due to dockerignore [pattern issue](https://github.com/moby/moby/pull/42676). Add directories to `.dockerignore`:
2121

2222
```patch
2323
!testdata/*.php
@@ -30,14 +30,14 @@ If your Docker version is lower than 23.0, the build will fail due to dockerigno
3030

3131
[Follow the instructions to compile from sources](https://frankenphp.dev/docs/compile/) and pass the `--debug` configuration flag.
3232

33-
## Running the test suite
33+
## Running the Test Suite
3434

3535
```console
36-
export CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)"
36+
export CGO_CFLAGS=-O0 -g $(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)"
3737
go test -race -v ./...
3838
```
3939

40-
## Caddy module
40+
## Caddy Module
4141

4242
Build Caddy with the FrankenPHP Caddy module:
4343

@@ -57,13 +57,13 @@ cd testdata/
5757
The server is listening on `127.0.0.1:80`:
5858

5959
> [!NOTE]
60-
> if you are using Docker, you will have to either bind container port 80 or execute from inside the container
60+
> If you are using Docker, you will have to either bind container port 80 or execute from inside the container
6161
6262
```console
6363
curl -vk http://127.0.0.1/phpinfo.php
6464
```
6565

66-
## Minimal test server
66+
## Minimal Test Server
6767

6868
Build the minimal test server:
6969

@@ -86,9 +86,76 @@ The server is listening on `127.0.0.1:8080`:
8686
curl -v http://127.0.0.1:8080/phpinfo.php
8787
```
8888

89+
## Windows Development
90+
91+
1. Configure Git to always use `lf` line endings
92+
93+
```powershell
94+
git config --global core.autocrlf false
95+
git config --global core.eol lf
96+
```
97+
98+
2. Install Visual Studio, Git, and Go:
99+
100+
```powershell
101+
winget install -e --id Microsoft.VisualStudio.2022.Community --override "--passive --wait --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --includeRecommended"
102+
winget install -e --id GoLang.Go
103+
winget install -e --id Git.Git
104+
```
105+
106+
3. Install vcpkg:
107+
108+
```powershell
109+
cd C:\
110+
git clone https://github.com/microsoft/vcpkg
111+
.\vcpkg\bootstrap-vcpkg.bat
112+
```
113+
114+
4. [Download the latest version of the watcher library for Windows](https://github.com/e-dant/watcher/releases) and extract it to a directory named `C:\watcher`
115+
5. [Download the latest **Thread Safe** version of PHP and of the PHP SDK for Windows](https://windows.php.net/download/), extract them in directories named `C:\php` and `C:\php-devel`
116+
6. Clone the FrankenPHP Git repository:
117+
118+
```powershell
119+
git clone https://github.com/php/frankenphp C:\frankenphp
120+
cd C:\frankenphp
121+
```
122+
123+
7. Install the dependencies:
124+
125+
```powershell
126+
C:\vcpkg\vcpkg.exe install
127+
```
128+
129+
8. Configure the needed environment variables (PowerShell):
130+
131+
```powershell
132+
$env:PATH += ';C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin'
133+
$env:CC = 'clang'
134+
$env:CXX = 'clang++'
135+
$env:CGO_CFLAGS = "-O0 -g -IC:\frankenphp\vcpkg_installed\x64-windows\include -IC:\watcher -IC:\php-devel\include -IC:\php-devel\include\main -IC:\php-devel\include\TSRM -IC:\php-devel\include\Zend -IC:\php-devel\include\ext"
136+
$env:CGO_LDFLAGS = '-LC:\frankenphp\vcpkg_installed\x64-windows\lib -lbrotlienc -LC:\watcher -llibwatcher-c -LC:\php -LC:\php-devel\lib -lphp8ts -lphp8embed'
137+
```
138+
139+
9. Run the tests:
140+
141+
```powershell
142+
go test -race -ldflags '-extldflags="-fuse-ld=lld"' ./...
143+
cd caddy
144+
go test -race -ldflags '-extldflags="-fuse-ld=lld"' -tags nobadger,nomysql,nopgx ./...
145+
cd ..
146+
```
147+
148+
10. Build the binary:
149+
150+
```powershell
151+
cd caddy/frankenphp
152+
go build -ldflags '-extldflags="-fuse-ld=lld"' -tags nobadger,nomysql,nopgx
153+
cd ../..
154+
```
155+
89156
## Building Docker Images Locally
90157
91-
Print bake plan:
158+
Print Bake plan:
92159
93160
```console
94161
docker buildx bake -f docker-bake.hcl --print
@@ -125,7 +192,7 @@ docker buildx bake -f docker-bake.hcl --pull --no-cache --push
125192
docker cp $(docker create --name static-builder-musl dunglas/frankenphp:static-builder-musl):/go/src/app/dist/frankenphp-linux-$(uname -m) frankenphp
126193
```
127194

128-
2. Replace your current version of `frankenphp` by the debug FrankenPHP executable
195+
2. Replace your current version of `frankenphp` with the debug FrankenPHP executable
129196
3. Start FrankenPHP as usual (alternatively, you can directly start FrankenPHP with GDB: `gdb --args frankenphp run`)
130197
4. Attach to the process with GDB:
131198

@@ -155,7 +222,7 @@ docker buildx bake -f docker-bake.hcl --pull --no-cache --push
155222

156223
```patch
157224
- name: Set CGO flags
158-
run: echo "CGO_CFLAGS=$(php-config --includes)" >> "$GITHUB_ENV"
225+
run: echo "CGO_CFLAGS=-O0 -g $(php-config --includes)" >> "$GITHUB_ENV"
159226
+ - run: |
160227
+ sudo apt install gdb
161228
+ mkdir -p /home/runner/.config/gdb/
@@ -207,14 +274,14 @@ strace -e 'trace=!futex,epoll_ctl,epoll_pwait,tgkill,rt_sigreturn' -p 1
207274

208275
## Translating the Documentation
209276

210-
To translate the documentation and the site in a new language,
277+
To translate the documentation and the site into a new language,
211278
follow these steps:
212279

213280
1. Create a new directory named with the language's 2-character ISO code in this repository's `docs/` directory
214281
2. Copy all the `.md` files in the root of the `docs/` directory into the new directory (always use the English version as source for translation, as it's always up to date)
215282
3. Copy the `README.md` and `CONTRIBUTING.md` files from the root directory to the new directory
216283
4. Translate the content of the files, but don't change the filenames, also don't translate strings starting with `> [!` (it's special markup for GitHub)
217284
5. Create a Pull Request with the translations
218-
6. In the [site repository](https://github.com/dunglas/frankenphp-website/tree/main), copy and translate the translation files in the `content/`, `data/` and `i18n/` directories
285+
6. In the [site repository](https://github.com/dunglas/frankenphp-website/tree/main), copy and translate the translation files in the `content/`, `data/`, and `i18n/` directories
219286
7. Translate the values in the created YAML file
220287
8. Open a Pull Request on the site repository

0 commit comments

Comments
 (0)