Skip to content

Commit 340b1fd

Browse files
committed
docs: improve compilation instructions
1 parent c9329bd commit 340b1fd

4 files changed

Lines changed: 79 additions & 55 deletions

File tree

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ You can also run command-line scripts with:
4343
frankenphp php-cli /path/to/your/script.php
4444
```
4545

46-
> [!WARNING]
47-
>
48-
> In production, prefer using [the Docker images](#docker), [the Brew package](#homebrew)
49-
> or [compiling FrankenPHP from sources](https://frankenphp.dev/docs/compile/).
50-
> The standalone binary is provided for development and testing purposes.
51-
5246
### Docker
5347

5448
Alternatively, [Docker images](https://frankenphp.dev/docs/docker/) are available:

docs/compile.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,30 @@
33
This document explains how to create a FrankenPHP binary that will load PHP as a dynamic library.
44
This is the recommended method.
55

6-
Alternatively, [static builds](static.md) can also be created.
6+
Alternatively, [fully and mostly static builds](static.md) can also be created.
77

88
## Install PHP
99

1010
FrankenPHP is compatible with PHP 8.2 and superior.
1111

12-
First, [get the PHP sources](https://www.php.net/downloads.php) and extract them:
12+
### With Homebrew (Linux and Mac)
13+
14+
The easiest way to install a version of libphp compatible with FrankenPHP is to use the ZTS packages provided by [Homebrew PHP](https://github.com/shivammathur/homebrew-php).
15+
16+
First, if not already done, install [Homebrew](https://brew.sh).
17+
18+
Then, install the ZTS variant of PHP, Brotli (optional, for compression support) and watcher (optional, for file change detection):
19+
20+
```console
21+
brew install shivammathur/php/php-zts brotli watcher
22+
brew link --overwrite --force shivammathur/php/php-zts
23+
```
24+
25+
### By Compiling PHP
26+
27+
Alternatively, you can compile PHP from sources with the options needed by FrankenPHP by following these steps.
28+
~~
29+
~~First, [get the PHP sources](https://www.php.net/downloads.php) and extract them:
1330

1431
```console
1532
tar xf php-*
@@ -19,7 +36,7 @@ cd php-*/
1936
Then, run the `configure` script with the options needed for your platform.
2037
The following `./configure` flags are mandatory, but you can add others, for example, to compile extensions or additional features.
2138

22-
### Linux
39+
#### Linux
2340

2441
```console
2542
./configure \
@@ -29,30 +46,26 @@ The following `./configure` flags are mandatory, but you can add others, for exa
2946
--enable-zend-max-execution-timers
3047
```
3148

32-
### Mac
49+
#### Mac
3350

34-
Use the [Homebrew](https://brew.sh/) package manager to install
35-
`libiconv`, `bison`, `re2c` and `pkg-config`:
51+
Use the [Homebrew](https://brew.sh/) package manager to install the required and optional dependencies:
3652

3753
```console
38-
brew install libiconv bison brotli re2c pkg-config
54+
brew install libiconv bison brotli re2c pkg-config watcher
3955
echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.zshrc
4056
```
4157

4258
Then run the configure script:
4359

4460
```console
4561
./configure \
46-
--enable-embed=static \
62+
--enable-embed \
4763
--enable-zts \
4864
--disable-zend-signals \
49-
--disable-opcache-jit \
50-
--enable-static \
51-
--enable-shared=no \
5265
--with-iconv=/opt/homebrew/opt/libiconv/
5366
```
5467

55-
## Compile PHP
68+
#### Compile PHP
5669

5770
Finally, compile and install PHP:
5871

@@ -67,23 +80,18 @@ Some FrankenPHP features depend on optional system dependencies that must be ins
6780
Alternatively, these features can be disabled by passing build tags to the Go compiler.
6881

6982
| Feature | Dependency | Build tag to disable it |
70-
| ------------------------------ | --------------------------------------------------------------------- | ----------------------- |
83+
|--------------------------------|-----------------------------------------------------------------------|-------------------------|
7184
| Brotli compression | [Brotli](https://github.com/google/brotli) | nobrotli |
7285
| Restart workers on file change | [Watcher C](https://github.com/e-dant/watcher/tree/release/watcher-c) | nowatcher |
7386

7487
## Compile the Go App
7588

76-
You can now build the final binary:
77-
78-
```console
79-
curl -L https://github.com/dunglas/frankenphp/archive/refs/heads/main.tar.gz | tar xz
80-
cd frankenphp-main/caddy/frankenphp
81-
CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build -tags=nobadger,nomysql,nopgx
82-
```
89+
You can now build the final binary.
8390

8491
### Using xcaddy
8592

86-
Alternatively, use [xcaddy](https://github.com/caddyserver/xcaddy) to compile FrankenPHP with [custom Caddy modules](https://caddyserver.com/docs/modules/):
93+
The recommended way is to use [xcaddy](https://github.com/caddyserver/xcaddy) to compile FrankenPHP.
94+
`xcaddy` also allows to easily add [custom Caddy modules](https://caddyserver.com/docs/modules/) and FrankenPHP extensions:
8795

8896
```console
8997
CGO_ENABLED=1 \
@@ -95,7 +103,7 @@ xcaddy build \
95103
--with github.com/dunglas/frankenphp/caddy \
96104
--with github.com/dunglas/mercure/caddy \
97105
--with github.com/dunglas/vulcain/caddy
98-
# Add extra Caddy modules here
106+
# Add extra Caddy modules and FrankenPHP extensions here
99107
```
100108

101109
> [!TIP]
@@ -107,3 +115,13 @@ xcaddy build \
107115
> To do so, change the `XCADDY_GO_BUILD_FLAGS` environment variable to something like
108116
> `XCADDY_GO_BUILD_FLAGS=$'-ldflags "-w -s -extldflags \'-Wl,-z,stack-size=0x80000\'"'`
109117
> (change the stack size value according to your app needs).
118+
119+
### Without xcaddy
120+
121+
Alternatively, it's possible to compile FrankenPHP without `xcaddy` by using the `go` command directly:
122+
123+
```console
124+
curl -L https://github.com/dunglas/frankenphp/archive/refs/heads/main.tar.gz | tar xz
125+
cd frankenphp-main/caddy/frankenphp
126+
CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build -tags=nobadger,nomysql,nopgx
127+
```

docs/fr/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ Vous pouvez également exécuter des scripts en ligne de commande avec :
4242
frankenphp php-cli /path/to/your/script.php
4343
```
4444

45-
> [!WARNING]
46-
>
47-
> En production, préférez utiliser [les images Docker](#docker), [le paquet Brew](#homebrew)
48-
> ou [compiler FrankenPHP à partir des sources](https://frankenphp.dev/docs/fr/compile/).
49-
> Le binaire autonome est fourni à des fins de développement et de test.
50-
5145
### Docker
5246

5347
Des [images Docker](https://frankenphp.dev/docs/fr/docker/) sont également disponibles :

docs/fr/compile.md

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ Alternativement, il est aussi possible de [créer des builds statiques](static.m
99

1010
FrankenPHP est compatible avec PHP 8.2 et versions ultérieures.
1111

12+
### Avec Homebrew (Linux et Mac)
13+
14+
La manière la plus simple d'installer une version de libphp compatible avec FrankenPHP est d'utiliser les paquets ZTS fournis par [Homebrew PHP](https://github.com/shivammathur/homebrew-php).
15+
16+
Tout d'abord, si ce n'est déjà fait, installez [Homebrew](https://brew.sh).
17+
18+
Ensuite, installez la variante ZTS de PHP, Brotli (facultatif, pour la prise en charge de la compression) et watcher (facultatif, pour la détection des modifications de fichiers) :
19+
20+
```console
21+
brew install shivammathur/php/php-zts brotli watcher
22+
brew link --overwrite --force shivammathur/php/php-zts
23+
```
24+
25+
### En compilant PHP
26+
27+
Vous pouvez également compiler PHP à partir des sources avec les options requises par FrankenPHP en suivant ces étapes.
28+
1229
Tout d'abord, [téléchargez les sources de PHP](https://www.php.net/downloads.php) et extrayez-les :
1330

1431
```console
@@ -32,27 +49,25 @@ Les options de configuration suivantes sont nécessaires pour la compilation, ma
3249

3350
### Mac
3451

35-
Utilisez le gestionnaire de paquets [Homebrew](https://brew.sh/) pour installer `libiconv`, `bison`, `re2c` et `pkg-config` :
52+
Utilisez le gestionnaire de paquets [Homebrew](https://brew.sh/) pour installer les dépendances obligatoires et optionnelles :
3653

3754
```console
38-
brew install libiconv bison brotli re2c pkg-config
55+
brew install libiconv bison brotli re2c pkg-config watcher
3956
echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.zshrc
4057
```
4158

4259
Puis exécutez le script de configuration :
4360

4461
```console
4562
./configure \
46-
--enable-embed=static \
63+
--enable-embed \
4764
--enable-zts \
4865
--disable-zend-signals \
4966
--disable-opcache-jit \
50-
--enable-static \
51-
--enable-shared=no \
5267
--with-iconv=/opt/homebrew/opt/libiconv/
5368
```
5469

55-
## Compilez PHP
70+
### Compilez PHP
5671

5772
Finalement, compilez et installez PHP :
5873

@@ -64,26 +79,19 @@ sudo make install
6479
## Installez les dépendances optionnelles
6580

6681
Certaines fonctionnalités de FrankenPHP nécessitent des dépendances optionnelles qui doivent être installées.
67-
Ces fonctionnalités peuvent également être désactivées en passant des balises de compilation au compilateur Go.
82+
Ces fonctionnalités peuvent également être désactivées en passant des tags de compilation au compilateur Go.
6883

69-
| Fonctionnalité | Dépendance | Balise de compilation pour la désactiver |
70-
| ------------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------- |
71-
| Compression Brotli | [Brotli](https://github.com/google/brotli) | nobrotli |
72-
| Redémarrage des workers en cas de changement de fichier | [Watcher C](https://github.com/e-dant/watcher/tree/release/watcher-c) | nowatcher |
84+
| Fonctionnalité | Dépendance | Tag de compilation pour la désactiver |
85+
|---------------------------------------------------------|-----------------------------------------------------------------------|---------------------------------------|
86+
| Compression Brotli | [Brotli](https://github.com/google/brotli) | nobrotli |
87+
| Redémarrage des workers en cas de changement de fichier | [Watcher C](https://github.com/e-dant/watcher/tree/release/watcher-c) | nowatcher |
7388

7489
## Compiler l'application Go
7590

76-
Vous pouvez maintenant compiler FrankenPHP :
77-
78-
```console
79-
curl -L https://github.com/dunglas/frankenphp/archive/refs/heads/main.tar.gz | tar xz
80-
cd frankenphp-main/caddy/frankenphp
81-
CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build -tags=nobadger,nomysql,nopgx
82-
```
83-
8491
### Utiliser xcaddy
8592

86-
Alternativement, vous pouvez utiliser [xcaddy](https://github.com/caddyserver/xcaddy) pour compiler FrankenPHP avec [des modules Caddy additionnels](https://caddyserver.com/docs/modules/) :
93+
La méthode recommandée consiste à utiliser [xcaddy](https://github.com/caddyserver/xcaddy) pour compiler FrankenPHP.
94+
`xcaddy` permet également d'ajouter facilement des [modules Caddy personnalisés](https://caddyserver.com/docs/modules/) et des extensions FrankenPHP :
8795

8896
```console
8997
CGO_ENABLED=1 \
@@ -96,7 +104,7 @@ xcaddy build \
96104
--with github.com/dunglas/caddy-cbrotli \
97105
--with github.com/dunglas/mercure/caddy \
98106
--with github.com/dunglas/vulcain/caddy
99-
# Add extra Caddy modules here
107+
# Ajoutez les modules Caddy supplémentaires et les extensions FrankenPHP ici
100108
```
101109

102110
> [!TIP]
@@ -108,3 +116,13 @@ xcaddy build \
108116
> Pour ce faire, modifiez la variable d'environnement `XCADDY_GO_BUILD_FLAGS` en quelque chose comme
109117
> `XCADDY_GO_BUILD_FLAGS=$'-ldflags "-w -s -extldflags \'-Wl,-z,stack-size=0x80000\'"'`
110118
> (modifiez la valeur de la taille de la pile selon les besoins de votre application).
119+
120+
### Sans xcaddy
121+
122+
Il est également possible de compiler FrankenPHP sans `xcaddy` en utilisant directement la commande `go` :
123+
124+
```console
125+
curl -L https://github.com/dunglas/frankenphp/archive/refs/heads/main.tar.gz | tar xz
126+
cd frankenphp-main/caddy/frankenphp
127+
CGO_CFLAGS=$(php-config --includes) CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" go build -tags=nobadger,nomysql,nopgx
128+
```

0 commit comments

Comments
 (0)