Skip to content

Commit

Permalink
docs: add FR translations and various EN improvements (#589)
Browse files Browse the repository at this point in the history
* feat: add fr doc (#1)

* fix: fr translations

* fix: linter

* docs: various improvements

* fix: md links on readme fr

* fix: remove duplicate images

---------

Co-authored-by: Kévin Dunglas <[email protected]>
  • Loading branch information
ginifizz and dunglas authored Feb 27, 2024
1 parent a6fc225 commit 963b3e0
Show file tree
Hide file tree
Showing 25 changed files with 1,412 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FrankenPHP is a modern application server for PHP built on top of the [Caddy](ht

FrankenPHP gives superpowers to your PHP apps thanks to its stunning features: [*Early Hints*](https://frankenphp.dev/docs/early-hints/), [worker mode](https://frankenphp.dev/docs/worker/), [real-time capabilities](https://frankenphp.dev/docs/mercure/), automatic HTTPS, HTTP/2, and HTTP/3 support...

FrankenPHP works with any PHP app and makes your Symfony and Laravel projects faster than ever thanks to the provided integration with the worker mode.
FrankenPHP works with any PHP app and makes your Laravel and Symfony projects faster than ever thanks to their official integrations with the worker mode.

FrankenPHP can also be used as a standalone Go library to embed PHP in any app using `net/http`.

Expand Down
11 changes: 6 additions & 5 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the Docker image, the `Caddyfile` is located at `/etc/caddy/Caddyfile`.

You can also configure PHP using `php.ini` as usual.

In the Docker image, the `php.ini` file is not present, you can create it or `COPY` manually:
In the Docker image, the `php.ini` file is not present, you can create it manually or copy an official template:

```dockerfile
FROM dunglas/frankenphp
Expand Down Expand Up @@ -88,7 +88,8 @@ other.example.com {
root * /path/to/other/public
php_server
}
...
# ...
```

Using the `php_server` directive is generally what you need,
Expand Down Expand Up @@ -122,7 +123,7 @@ The `php_server` and the `php` directives have the following options:
```caddyfile
php_server [<matcher>] {
root <directory> # Sets the root folder to the site. Default: `root` directive.
split_path <delim...> # Sets the substrings for splitting the URI into two parts. The first matching substring will be used to split the "path info" from the path. The first piece is suffixed with the matching substring and will be assumed as the actual resource (CGI script) name. The second piece will be set to PATH_INFO for the CGI script to use. Default: `.php`
split_path <delim...> # Sets the substrings for splitting the URI into two parts. The first matching substring will be used to split the "path info" from the path. The first piece is suffixed with the matching substring and will be assumed as the actual resource (CGI script) name. The second piece will be set to PATH_INFO for the script to use. Default: `.php`
resolve_root_symlink false # Disables resolving the `root` directory to its actual value by evaluating a symbolic link, if one exists (enabled by default).
env <key> <value> # Sets an extra environment variable to the given value. Can be specified more than once for multiple environment variables.
}
Expand All @@ -136,9 +137,9 @@ The following environment variables can be used to inject Caddy directives in th
* `CADDY_GLOBAL_OPTIONS`: inject [global options](https://caddyserver.com/docs/caddyfile/options)
* `FRANKENPHP_CONFIG`: inject config under the `frankenphp` directive

Unlike with FPM and CLI SAPIs, environment variables are **not** exposed by default in superglobals `$_SERVER` and `$_ENV`.
As for FPM and CLI SAPIs, environment variables are exposed by default in the `$_SERVER` superglobal.

To propagate environment variables to `$_SERVER` and `$_ENV`, set the `php.ini` `variables_order` directive to `EGPCS`.
The `S` value of [the `variables_order` PHP directive](https://www.php.net/manual/en/ini.core.php#ini.variables-order) is always equivalent to `ES` regardless of the placement of `E` elsewhere in this directive.

## PHP config

Expand Down
10 changes: 6 additions & 4 deletions docs/docker.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Building Custom Docker Image

[FrankenPHP Docker images](https://hub.docker.com/r/dunglas/frankenphp) are based on [official PHP images](https://hub.docker.com/_/php/). Alpine Linux and Debian variants are provided for popular architectures. Variants for PHP 8.2 and PHP 8.3 are provided. [Browse tags](https://hub.docker.com/r/dunglas/frankenphp/tags).
[FrankenPHP Docker images](https://hub.docker.com/r/dunglas/frankenphp) are based on [official PHP images](https://hub.docker.com/_/php/). Debian and Alpine Linux avariants are provided for popular architectures. Debian variants are recommended.

Variants for PHP 8.2 and PHP 8.3 are provided. [Browse tags](https://hub.docker.com/r/dunglas/frankenphp/tags).

## How to Use The Images

Expand All @@ -12,7 +14,7 @@ FROM dunglas/frankenphp
COPY . /app/public
```

Then, run the commands to build and run the Docker image:
Then, run these commands to build and run the Docker image:

```console
docker build -t my-php-app .
Expand Down Expand Up @@ -65,8 +67,8 @@ FROM dunglas/frankenphp AS runner
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
```

The `builder` image provided by FrankenPHP contains a compiled version of libphp.
[Builders images](https://hub.docker.com/r/dunglas/frankenphp/tags?name=builder) are provided for all versions of FrankenPHP and PHP, both for Alpine and Debian.
The `builder` image provided by FrankenPHP contains a compiled version of `libphp`.
[Builders images](https://hub.docker.com/r/dunglas/frankenphp/tags?name=builder) are provided for all versions of FrankenPHP and PHP, both for Debian and Alpine.

> [!TIP]
>
Expand Down
8 changes: 4 additions & 4 deletions docs/embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FrankenPHP has the ability to embed the source code and assets of PHP applicatio

Thanks to this feature, PHP applications can be distributed as standalone binaries that include the application itself, the PHP interpreter and Caddy, a production-level web server.

Learn more about this feature [in the presentation made by Kévin at SymfonyCon](https://dunglas.dev/2023/12/php-and-symfony-apps-as-standalone-binaries/).
Learn more about this feature [in the presentation made by Kévin at SymfonyCon 2023](https://dunglas.dev/2023/12/php-and-symfony-apps-as-standalone-binaries/).

## Preparing Your App

Expand Down Expand Up @@ -65,7 +65,7 @@ The easiest way to create a Linux binary is to use the Docker-based builder we p
docker build -t static-app -f static-build.Dockerfile .
```

3. Extract the binary
3. Extract the binary:

```console
docker cp $(docker create --name static-app-tmp static-app):/go/src/app/dist/frankenphp-linux-x86_64 my-app ; docker rm static-app-tmp
Expand Down Expand Up @@ -121,7 +121,7 @@ You can also run the PHP CLI scripts embedded in your binary:

## Distributing The Binary

The created binary isn't compressed.
To reduce the size of the file before sending it, you can compress it.
On Linux, the created binary is compressed using [UPX](https://upx.github.io).

On Mac, to reduce the size of the file before sending it, you can compress it.
We recommend `xz`.
177 changes: 177 additions & 0 deletions docs/fr/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Contribuer

## Compiler PHP

### Avec Docker (Linux)

Construisez l'image Docker de développement :

```console
docker build -t frankenphp-dev -f dev.Dockerfile .
docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -p 8080:8080 -p 443:443 -p 443:443/udp -v $PWD:/go/src/app -it frankenphp-dev
```

L'image contient les outils de développement habituels (Go, GDB, Valgrind, Neovim...).

Si la version de Docker est inférieure à 23.0, la construction échoue à cause d'un [problème de pattern](https://github.com/moby/moby/pull/42676) dans `.dockerignore`. Ajoutez les répertoires à `.dockerignore`.

```patch
!testdata/*.php
!testdata/*.txt
+!caddy
+!C-Thread-Pool
+!internal
```

### Sans Docker (Linux et macOS)

[Suivez les instructions pour compiler à partir des sources](compile.md) et passez l'indicateur de configuration `--debug`.

## Exécution de la suite de tests

```console
go test -race -v ./...
```

## Module Caddy

Construire Caddy avec le module FrankenPHP :

```console
cd caddy/frankenphp/
go build
cd ../../
```

Exécuter Caddy avec le module FrankenPHP :

```console
cd testdata/
../caddy/frankenphp/frankenphp run
```

Le serveur est configuré pour écouter à l'adresse `127.0.0.1:8080`:

```console
curl -vk https://localhost/phpinfo.php
```

## Serveur de test minimal

Construire le serveur de test minimal :

```console
cd internal/testserver/
go build
cd ../../
```

Lancer le test serveur :

```console
cd testdata/
../internal/testserver/testserver
```

Le serveur est configuré pour écouter à l'adresse `127.0.0.1:8080`:

```console
curl -v http://127.0.0.1:8080/phpinfo.php
```

## Construire localement les images Docker

Afficher le plan de compilation :

```console
docker buildx bake -f docker-bake.hcl --print
```

Construire localement les images FrankenPHP pour amd64 :

```console
docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/amd64"
```

Construire localement les images FrankenPHP pour arm64 :

```console
docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/arm64"
```

Construire à partir de zéro les images FrankenPHP pour arm64 & amd64 et les pousser sur Docker Hub :

```console
docker buildx bake -f docker-bake.hcl --pull --no-cache --push
```

## Déboguer les erreurs de segmentation dans GitHub Actions

1. Ouvrir `.github/workflows/tests.yml`
2. Activer les symboles de débogage de la bibliothèque PHP

```patch
- uses: shivammathur/setup-php@v2
# ...
env:
phpts: ts
+ debug: true
```

3. Activer `tmate` pour se connecter au conteneur

```patch
-
name: Set CGO flags
run: echo "CGO_CFLAGS=$(php-config --includes)" >> "$GITHUB_ENV"
+ -
+ run: |
+ sudo apt install gdb
+ mkdir -p /home/runner/.config/gdb/
+ printf "set auto-load safe-path /\nhandle SIG34 nostop noprint pass" > /home/runner/.config/gdb/gdbinit
+ -
+ uses: mxschmitt/action-tmate@v3
```

4. Se connecter au conteneur
5. Ouvrir `frankenphp.go`
6. Activer `cgosymbolizer`

```patch
- //_ "github.com/ianlancetaylor/cgosymbolizer"
+ _ "github.com/ianlancetaylor/cgosymbolizer"
```

7. Télécharger le module : `go get`
8. Dans le conteneur, vous pouvez utiliser GDB et similaires :

```console
go test -c -ldflags=-w
gdb --args ./frankenphp.test -test.run ^MyTest$
```

9. Quand le bug est corrigé, annulez tous les changements

## Ressources Diverses pour le Développement

* [Intégration de PHP dans uWSGI](https://github.com/unbit/uwsgi/blob/master/plugins/php/php_plugin.c)
* [Intégration de PHP dans NGINX Unit](https://github.com/nginx/unit/blob/master/src/nxt_php_sapi.c)
* [Intégration de PHP dans Go (go-php)](https://github.com/deuill/go-php)
* [Intégration de PHP dans Go (GoEmPHP)](https://github.com/mikespook/goemphp)
* [Intégration de PHP dans C++](https://gist.github.com/paresy/3cbd4c6a469511ac7479aa0e7c42fea7)
* [Extending and Embedding PHP par Sara Golemon](https://books.google.fr/books?id=zMbGvK17_tYC&pg=PA254&lpg=PA254#v=onepage&q&f=false)
* [Qu'est-ce que TSRMLS_CC, au juste ?](http://blog.golemon.com/2006/06/what-heck-is-tsrmlscc-anyway.html)
* [Intégration de PHP sur Mac](https://gist.github.com/jonnywang/61427ffc0e8dde74fff40f479d147db4)
* [Bindings SDL](https://pkg.go.dev/github.com/veandco/[email protected]/sdl#Main)

## Ressources Liées à Docker

* [Définition du fichier Bake](https://docs.docker.com/build/customize/bake/file-definition/)
* [docker buildx build](https://docs.docker.com/engine/reference/commandline/buildx_build/)

## Commande utile

```console
apk add strace util-linux gdb
strace -e 'trace=!futex,epoll_ctl,epoll_pwait,tgkill,rt_sigreturn' -p 1
```
77 changes: 77 additions & 0 deletions docs/fr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# FrankenPHP : le serveur d'applications PHP moderne, écrit en Go

<h1 align="center"><a href="https://frankenphp.dev"><img src="../../frankenphp.png" alt="FrankenPHP" width="600"></a></h1>

FrankenPHP est un serveur d'applications moderne pour PHP construit à partir du serveur web [Caddy](https://caddyserver.com/).

FrankenPHP donne des super-pouvoirs à vos applications PHP grâce à ses fonctionnalités à la pointe : [*Early Hints*](early-hints.md), [mode worker](worker.md), [fonctionnalités en temps réel](mercure.md), HTTPS automatique, prise en charge de HTTP/2 et HTTP/3...

FrankenPHP fonctionne avec n'importe quelle application PHP et rend vos projets Laravel et Symfony plus rapides que jamais grâce à leurs intégrations officielles avec le mode worker.

FrankenPHP peut également être utilisé comme une bibliothèque Go autonome qui permet d'intégrer PHP dans n'importe quelle application en utilisant `net/http`.

Découvrez plus de détails sur ce serveur d’application dans le replay de cette conférence donnée au Forum PHP 2022 :

<a href="https://dunglas.dev/2022/10/frankenphp-the-modern-php-app-server-written-in-go/"><img src="https://dunglas.dev/wp-content/uploads/2022/10/frankenphp.png" alt="Diapositives" width="600"></a>

## Pour Commencer

### Docker

```console
docker run -v $PWD:/app/public \
-p 80:80 -p 443:443 -p 443:443/udp \
dunglas/frankenphp
```

Rendez-vous sur `https://localhost`, c'est parti !

> [!TIP]
>
> Ne tentez pas d'utiliser `https://127.0.0.1`. Utilisez localhost et acceptez le certificat auto-signé.
> Utilisez [la variable d'environnement `SERVER_NAME`](config.md#environment-variables) pour changer le domaine à utiliser.
### Binaire autonome

Si vous préférez ne pas utiliser Docker, nous fournissons des binaires autonomes de FrankenPHP pour Linux et macOS
contenant [PHP 8.3](https://www.php.net/releases/8.3/fr.php) et la plupart des extensions PHP populaires : [Télécharger FrankenPHP](https://github.com/dunglas/frankenphp/releases)

Pour servir le contenu du répertoire courant, exécutez :

```console
./frankenphp php-server
```

Vous pouvez également exécuter des scripts en ligne de commande avec :

```console
./frankenphp php-cli /path/to/your/script.php
```

## Documentation

* [Le mode worker](worker.md)
* [Le support des Early Hints (code de statut HTTP 103)](early-hints.md)
* [Temps réel](mercure.md)
* [Configuration](config.md)
* [Images Docker](docker.md)
* [Déploiement en production](production.md)
* [Créer des applications PHP **standalone**, auto-exécutables](embed.md)
* [Créer un build statique](static.md)
* [Compiler depuis les sources](compile.md)
* [Intégration Laravel](laravel.md)
* [Problèmes connus](known-issues.md)
* [Application de démo (Symfony) et benchmarks](https://github.com/dunglas/frankenphp-demo)
* [Documentation de la bibliothèque Go](https://pkg.go.dev/github.com/dunglas/frankenphp)
* [Contribuer et débugger](CONTRIBUTING.md)

## Exemples et squelettes

* [Symfony](https://github.com/dunglas/symfony-docker)
* [API Platform](https://api-platform.com/docs/distribution/)
* [Laravel](laravel.md)
* [Sulu](https://sulu.io/blog/running-sulu-with-frankenphp)
* [WordPress](https://github.com/dunglas/frankenphp-wordpress)
* [Drupal](https://github.com/dunglas/frankenphp-drupal)
* [Joomla](https://github.com/alexandreelise/frankenphp-joomla)
* [TYPO3](https://github.com/ochorocho/franken-typo3)
Loading

0 comments on commit 963b3e0

Please sign in to comment.