From 097563d2629f767e30a384c036f70dc9b72e17e7 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois <2144837+alexandre-daubois@users.noreply.github.com> Date: Mon, 16 Mar 2026 03:38:14 +0100 Subject: [PATCH] feat(docs): add autocompletion docs (#2010) Co-authored-by: henderkes --- .github/workflows/windows.yaml | 2 +- .gitignore | 1 + Dockerfile | 2 +- alpine.Dockerfile | 2 +- docs/config.md | 75 ++++++++++++++++++++++++++++++++++ docs/fr/config.md | 75 ++++++++++++++++++++++++++++++++++ 6 files changed, 154 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 2602a8bc..73ec68b0 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -193,7 +193,7 @@ jobs: - name: Build FrankenPHP run: | $customVersion = "FrankenPHP $env:FRANKENPHP_VERSION PHP $env:PHP_VERSION Caddy" - go build -ldflags="-extldflags=-fuse-ld=lld -X 'github.com/caddyserver/caddy/v2.CustomVersion=$customVersion' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" + go build -ldflags="-extldflags=-fuse-ld=lld -X 'github.com/caddyserver/caddy/v2.CustomVersion=$customVersion' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" working-directory: frankenphp\caddy\frankenphp - name: Create Directory diff --git a/.gitignore b/.gitignore index d4ab524e..34f7a0fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /caddy/frankenphp/Build /caddy/frankenphp/frankenphp +/caddy/frankenphp/frankenphp.exe /dist /github_conf /internal/testserver/testserver diff --git a/Dockerfile b/Dockerfile index c40488b8..8252e409 100644 --- a/Dockerfile +++ b/Dockerfile @@ -118,7 +118,7 @@ ENV CGO_LDFLAGS="-L/usr/local/lib -lssl -lcrypto -lreadline -largon2 -lcurl -lon WORKDIR /go/src/app/caddy/frankenphp RUN GOBIN=/usr/local/bin \ - ../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \ + ../../go.sh install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \ setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \ cp Caddyfile /etc/frankenphp/Caddyfile && \ frankenphp version && \ diff --git a/alpine.Dockerfile b/alpine.Dockerfile index 31650af4..c5d0f64e 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -123,7 +123,7 @@ ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLA WORKDIR /go/src/app/caddy/frankenphp RUN GOBIN=/usr/local/bin \ - ../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \ + ../../go.sh install -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000' -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION PHP $PHP_VERSION Caddy' -X 'github.com/caddyserver/caddy/v2.CustomBinaryName=frankenphp' -X 'github.com/caddyserver/caddy/v2/modules/caddyhttp.ServerHeader=FrankenPHP Caddy'" -buildvcs=true && \ setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp && \ ([ -z "${NO_COMPRESS}" ] && upx --best /usr/local/bin/frankenphp || true) && \ frankenphp version && \ diff --git a/docs/config.md b/docs/config.md index 77c432b9..bfcdeb12 100644 --- a/docs/config.md +++ b/docs/config.md @@ -348,3 +348,78 @@ docker run -v $PWD:/app/public \ -p 80:80 -p 443:443 -p 443:443/udp \ dunglas/frankenphp ``` + +## Shell Completion + +FrankenPHP provides built-in shell completion support for Bash, Zsh, Fish, and PowerShell. This enables autocompletion for all commands (including custom commands like `php-server`, `php-cli`, and `extension-init`) and their flags. + +### Bash + +To load completions in your current shell session: + +```console +source <(frankenphp completion bash) +``` + +To load completions for every new session, run: + +**Linux:** + +```console +frankenphp completion bash > /usr/share/bash-completion/completions/frankenphp +``` + +**macOS:** + +```console +frankenphp completion bash > $(brew --prefix)/share/bash-completion/completions/frankenphp +``` + +### Zsh + +If shell completion is not already enabled in your environment, you will need to enable it. You can execute the following once: + +```console +echo "autoload -U compinit; compinit" >> ~/.zshrc +``` + +To load completions for each session, execute once: + +```console +frankenphp completion zsh > "${fpath[1]}/_frankenphp" +``` + +You will need to start a new shell for this setup to take effect. + +### Fish + +To load completions in your current shell session: + +```console +frankenphp completion fish | source +``` + +To load completions for every new session, execute once: + +```console +frankenphp completion fish > ~/.config/fish/completions/frankenphp.fish +``` + +### PowerShell + +To load completions in your current shell session: + +```powershell +frankenphp completion powershell | Out-String | Invoke-Expression +``` + +To load completions for every new session, execute once: + +```powershell +frankenphp completion powershell | Out-File -FilePath (Join-Path (Split-Path $PROFILE) "frankenphp.ps1") +Add-Content -Path $PROFILE -Value '. (Join-Path (Split-Path $PROFILE) "frankenphp.ps1")' +``` + +You will need to start a new shell for this setup to take effect. + +You will need to start a new shell for this setup to take effect. diff --git a/docs/fr/config.md b/docs/fr/config.md index be6183c2..e6fc79eb 100644 --- a/docs/fr/config.md +++ b/docs/fr/config.md @@ -342,3 +342,78 @@ docker run -v $PWD:/app/public \ -p 80:80 -p 443:443 -p 443:443/udp \ dunglas/frankenphp ``` + +## Autocomplétion Shell + +FrankenPHP fournit un support d'autocomplétion intégré pour Bash, Zsh, Fish et PowerShell. Cela permet l'autocomplétion de toutes les commandes (y compris les commandes personnalisées comme `php-server`, `php-cli` et `extension-init`) ainsi que leurs options. + +### Bash + +Pour charger l'autocomplétion dans votre session shell actuelle : + +```console +source <(frankenphp completion bash) +``` + +Pour charger l'autocomplétion à chaque nouvelle session, exécutez : + +**Linux :** + +```console +frankenphp completion bash > /usr/share/bash-completion/completions/frankenphp +``` + +**macOS :** + +```console +frankenphp completion bash > $(brew --prefix)/share/bash-completion/completions/frankenphp +``` + +### Zsh + +Si l'autocomplétion shell n'est pas déjà activée dans votre environnement, vous devrez l'activer. Vous pouvez exécuter la commande suivante une fois : + +```console +echo "autoload -U compinit; compinit" >> ~/.zshrc +``` + +Pour charger l'autocomplétion à chaque session, exécutez une fois : + +```console +frankenphp completion zsh > "${fpath[1]}/_frankenphp" +``` + +Vous devrez démarrer un nouveau shell pour que cette configuration prenne effet. + +### Fish + +Pour charger l'autocomplétion dans votre session shell actuelle : + +```console +frankenphp completion fish | source +``` + +Pour charger l'autocomplétion à chaque nouvelle session, exécutez une fois : + +```console +frankenphp completion fish > ~/.config/fish/completions/frankenphp.fish +``` + +### PowerShell + +Pour charger l'autocomplétion dans votre session shell actuelle : + +```powershell +frankenphp completion powershell | Out-String | Invoke-Expression +``` + +Pour charger l'autocomplétion à chaque nouvelle session, exécutez une fois : + +```powershell +frankenphp completion powershell | Out-File -FilePath (Join-Path (Split-Path $PROFILE) "frankenphp.ps1") +Add-Content -Path $PROFILE -Value '. (Join-Path (Split-Path $PROFILE) "frankenphp.ps1")' +``` + +Vous devrez démarrer un nouveau shell pour que cette configuration prenne effet. + +Vous devrez ensuite démarrer un nouveau shell pour que cette configuration prenne effet.