You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/config.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,7 +149,7 @@ The `php_server` and the `php` directives have the following options:
149
149
150
150
```caddyfile
151
151
php_server [<matcher>] {
152
-
root <directory> # Sets the root folder to the site. Default: `root` directive.
152
+
root <directory> # Sets the root folder to the site. Default: `root` directive. If not specified, it will use the current_working_dir/public directory by default.
153
153
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`
154
154
resolve_root_symlink false # Disables resolving the `root` directory to its actual value by evaluating a symbolic link, if one exists (enabled by default).
155
155
env <key> <value> # Sets an extra environment variable to the given value. Can be specified more than once for multiple environment variables.
@@ -265,6 +265,43 @@ You can also change the PHP configuration using the `php_ini` directive in the `
265
265
}
266
266
```
267
267
268
+
## The php-server Command
269
+
270
+
The `php-server` command is a convenient way to start a production-ready PHP server. It's especially useful for quick deployments, demos, development, or to run an [embedded app](embed.md).
-`--domain`, `-d`: Domain name at which to serve the files. If specified, the server will use HTTPS and automatically obtain a Let's Encrypt certificate.
279
+
-`--root`, `-r`: The path to the root of the site. If not specified and using an embedded app, it will use the embedded_app/public directory by default.
280
+
-`--listen`, `-l`: The address to which to bind the listener. Default is `:80` or `:443` if a domain is specified.
281
+
-`--worker`, `-w`: Worker script to run. Can be specified multiple times for multiple workers.
282
+
-`--watch`: Directory to watch for file changes. Can be specified multiple times for multiple directories.
283
+
-`--access-log`, `-a`: Enable the access log.
284
+
-`--debug`, `-v`: Enable verbose debug logs.
285
+
-`--mercure`, `-m`: Enable the built-in Mercure.rocks hub.
286
+
-`--no-compress`: Disable Zstandard, Brotli and Gzip compression.
287
+
288
+
### Examples
289
+
290
+
Start a server with the current directory as the document root:
291
+
```console
292
+
frankenphp php-server --root ./
293
+
```
294
+
295
+
Start a server with HTTPS enabled:
296
+
```console
297
+
frankenphp php-server --domain example.com
298
+
```
299
+
300
+
Start a server with a worker:
301
+
```console
302
+
frankenphp php-server --worker public/index.php
303
+
```
304
+
268
305
## Enable the Debug Mode
269
306
270
307
When using the Docker image, set the `CADDY_GLOBAL_OPTIONS` environment variable to `debug` to enable the debug mode:
Copy file name to clipboardExpand all lines: docs/embed.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,8 @@ composer dump-env prod
47
47
To customize [the configuration](config.md), you can put a `Caddyfile` as well as a `php.ini` file
48
48
in the main directory of the app to be embedded (`$TMPDIR/my-prepared-app` in the previous example).
49
49
50
+
If an app with a Caddyfile in the directory is embedded, it will use that Caddyfile's configuration automatically when running the binary.
51
+
50
52
## Creating a Linux Binary
51
53
52
54
The easiest way to create a Linux binary is to use the Docker-based builder we provide.
@@ -106,6 +108,12 @@ To start the web app run:
106
108
./my-app php-server
107
109
```
108
110
111
+
By default, if no root option is specified, it will use the embedded_app/public directory as the document root. If you want to serve directly from the embedded app directory, specify the root option:
112
+
113
+
```console
114
+
./my-app php-server --root ./
115
+
```
116
+
109
117
If your app contains a [worker script](worker.md), start the worker with something like:
Copy file name to clipboardExpand all lines: docs/fr/config.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ Les directives `php_server` et `php` disposent des options suivantes :
148
148
149
149
```caddyfile
150
150
php_server [<matcher>] {
151
-
root <directory> # Définit le dossier racine du le site. Par défaut : valeur de la directive `root` parente.
151
+
root <directory> # Définit le dossier racine du le site. Par défaut : valeur de la directive `root` parente. Si non spécifié, il utilisera le répertoire current_working_dir/public par défaut.
152
152
split_path <delim...> # Définit les sous-chaînes pour diviser l'URI en deux parties. La première sous-chaîne correspondante sera utilisée pour séparer le "path info" du chemin. La première partie est suffixée avec la sous-chaîne correspondante et sera considérée comme le nom réel de la ressource (script CGI). La seconde partie sera définie comme PATH_INFO pour utilisation par le script. Par défaut : `.php`
153
153
resolve_root_symlink false # Désactive la résolution du répertoire `root` vers sa valeur réelle en évaluant un lien symbolique, s'il existe (activé par défaut).
154
154
env <key> <value> # Définit une variable d'environnement supplémentaire avec la valeur donnée. Peut être spécifié plusieurs fois pour plusieurs variables d'environnement.
@@ -264,6 +264,43 @@ Vous pouvez également modifier la configuration de PHP en utilisant la directiv
264
264
}
265
265
```
266
266
267
+
## La commande php-server
268
+
269
+
La commande `php-server` est un moyen pratique de démarrer un serveur PHP prêt pour la production. Elle est particulièrement utile pour les déploiements rapides, les démonstrations, le développement, ou pour exécuter une [application embarquée](embed.md).
-`--domain`, `-d` : Nom de domaine sur lequel servir les fichiers. Si spécifié, le serveur utilisera HTTPS et obtiendra automatiquement un certificat Let's Encrypt.
278
+
-`--root`, `-r` : Chemin vers la racine du site. Si non spécifié et en utilisant une application embarquée, il utilisera le répertoire embedded_app/public par défaut.
279
+
-`--listen`, `-l` : L'adresse à laquelle lier l'écouteur. Par défaut, c'est `:80` ou `:443` si un domaine est spécifié.
280
+
-`--worker`, `-w` : Script worker à exécuter. Peut être spécifié plusieurs fois pour plusieurs workers.
281
+
-`--watch` : Répertoire à surveiller pour les changements de fichiers. Peut être spécifié plusieurs fois pour plusieurs répertoires.
282
+
-`--access-log`, `-a` : Activer le journal d'accès.
283
+
-`--debug`, `-v` : Activer les journaux de débogage détaillés.
284
+
-`--mercure`, `-m` : Activer le hub Mercure.rocks intégré.
285
+
-`--no-compress` : Désactiver la compression Zstandard, Brotli et Gzip.
286
+
287
+
### Exemples
288
+
289
+
Démarrer un serveur avec le répertoire courant comme racine de document :
290
+
```console
291
+
frankenphp php-server --root ./
292
+
```
293
+
294
+
Démarrer un serveur avec HTTPS activé :
295
+
```console
296
+
frankenphp php-server --domain example.com
297
+
```
298
+
299
+
Démarrer un serveur avec un worker :
300
+
```console
301
+
frankenphp php-server --worker public/index.php
302
+
```
303
+
267
304
## Activer le mode debug
268
305
269
306
Lors de l'utilisation de l'image Docker, définissez la variable d'environnement `CADDY_GLOBAL_OPTIONS` sur `debug` pour activer le mode debug :
Copy file name to clipboardExpand all lines: docs/fr/embed.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,7 @@ Pour personnaliser [la configuration](config.md),
48
48
vous pouvez mettre un fichier `Caddyfile` ainsi qu'un fichier `php.ini`
49
49
dans le répertoire principal de l'application à intégrer
50
50
(`$TMPDIR/my-prepared-app` dans l'exemple précédent).
51
+
Si une application avec un Caddyfile dans le répertoire est intégrée, elle utilisera automatiquement la configuration de ce Caddyfile lors de l'exécution du binaire.
51
52
52
53
## Créer un binaire Linux
53
54
@@ -108,6 +109,12 @@ Pour démarrer l'application web, exécutez :
108
109
./my-app php-server
109
110
```
110
111
112
+
Par défaut, si aucune option root n'est spécifiée, il utilisera le répertoire embedded_app/public comme racine de document. Si vous souhaitez servir directement depuis le répertoire de l'application embarquée, spécifiez l'option root :
113
+
114
+
```console
115
+
./my-app php-server --root ./
116
+
```
117
+
111
118
Si votre application contient un [script worker](worker.md), démarrez le worker avec quelque chose comme :
Copy file name to clipboardExpand all lines: docs/ru/config.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ route {
141
141
142
142
```caddyfile
143
143
php_server [<matcher>] {
144
-
root <directory> # Указывает корневую директорию сайта. По умолчанию: директива `root`.
144
+
root <directory> # Указывает корневую директорию сайта. По умолчанию: директива `root`. Если не указано, по умолчанию будет использоваться директория current_working_dir/public.
145
145
split_path <delim...> # Устанавливает подстроки для разделения URI на две части. Первая часть будет использована как имя ресурса (CGI-скрипта), вторая часть — как PATH_INFO. По умолчанию: `.php`.
146
146
resolve_root_symlink false # Отключает разрешение символьных ссылок для `root` (включено по умолчанию).
147
147
env <key> <value> # Устанавливает дополнительные переменные окружения. Можно указать несколько раз для разных переменных.
Для загрузки [дополнительных конфигурационных файлов PHP](https://www.php.net/manual/en/configuration.file.php#configuration.file.scan) можно использовать переменную окружения `PHP_INI_SCAN_DIR`.
235
235
Если она установлена, PHP загрузит все файлы с расширением `.ini`, находящиеся в указанных директориях.
236
236
237
+
## Команда php-server
238
+
239
+
Команда `php-server` — это удобный способ запустить готовый к продакшну PHP-сервер. Она особенно полезна для быстрого развертывания, демонстраций, разработки или запуска [встроенного приложения](embed.md).
-`--domain`, `-d`: Доменное имя, на котором будут обслуживаться файлы. Если указано, сервер будет использовать HTTPS и автоматически получит сертификат Let's Encrypt.
248
+
-`--root`, `-r`: Путь к корневой директории сайта. Если не указано и используется встроенное приложение, по умолчанию будет использоваться директория embedded_app/public.
249
+
-`--listen`, `-l`: Адрес, к которому будет привязан слушатель. По умолчанию `:80` или `:443`, если указан домен.
250
+
-`--worker`, `-w`: Скрипт worker для запуска. Может быть указан несколько раз для нескольких workers.
251
+
-`--watch`: Директория для отслеживания изменений файлов. Может быть указана несколько раз для нескольких директорий.
Copy file name to clipboardExpand all lines: docs/ru/embed.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ composer dump-env prod
44
44
### Настройка конфигурации
45
45
46
46
Чтобы настроить [конфигурацию](config.md), вы можете разместить файлы `Caddyfile` и `php.ini` в основной директории приложения (`$TMPDIR/my-prepared-app` в примере выше).
47
+
Если приложение с файлом Caddyfile в директории встроено, оно будет автоматически использовать конфигурацию из этого Caddyfile при запуске бинарного файла.
По умолчанию, если опция root не указана, будет использоваться директория embedded_app/public в качестве корневой. Если вы хотите обслуживать файлы непосредственно из директории встроенного приложения, укажите опцию root:
109
+
110
+
```console
111
+
./my-app php-server --root ./
112
+
```
113
+
107
114
Если ваше приложение содержит [worker-скрипт](worker.md), запустите его следующим образом:
0 commit comments