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: caddy/extinit.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ func init() {
17
17
caddycmd.RegisterCommand(caddycmd.Command{
18
18
Name: "extension-init",
19
19
Usage: "go_extension.go [--verbose]",
20
-
Short: "(Experimental) Initializes a PHP extension from a Go file",
20
+
Short: "Initializes a PHP extension from a Go file (EXPERIMENTAL)",
21
21
Long: `
22
22
Initializes a PHP extension from a Go file. This command generates the necessary C files for the extension, including the header and source files, as well as the arginfo file.`,
Copy file name to clipboardExpand all lines: docs/config.md
+75-32Lines changed: 75 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,38 @@
1
1
# Configuration
2
2
3
-
FrankenPHP, Caddy as well as the Mercure and Vulcain modules can be configured using [the formats supported by Caddy](https://caddyserver.com/docs/getting-started#your-first-config).
3
+
FrankenPHP, Caddy as well as the [Mercure](mercure.md) and [Vulcain](https://vulcain.rocks) modules can be configured using [the formats supported by Caddy](https://caddyserver.com/docs/getting-started#your-first-config).
4
4
5
-
In [the Docker images](docker.md), the `Caddyfile`is located at `/etc/frankenphp/Caddyfile`.
6
-
The static binary will also look for the`Caddyfile` in the directory where the `frankenphp run` command is executed.
5
+
The most common format is the `Caddyfile`, which is a simple, human-readable text format.
6
+
By default, FrankenPHP will look for a`Caddyfile` in the current directory.
7
7
You can specify a custom path with the `-c` or `--config` option.
8
8
9
+
A minimal `Caddyfile` to serve a PHP application is shown below:
10
+
11
+
```caddyfile
12
+
# The hostname to respond to
13
+
localhost
14
+
15
+
# Optionaly, the directory to serve files from, otherwise defaults to the current directory
16
+
#root public/
17
+
php_server
18
+
```
19
+
20
+
A more advanced `Caddyfile` enabling more features and providing convenient environment variables is provided [in the FrankenPHP repository](https://github.com/php/frankenphp/blob/main/caddy/frankenphp/Caddyfile),
21
+
and with Docker images.
22
+
9
23
PHP itself can be configured [using a `php.ini` file](https://www.php.net/manual/en/configuration.file.php).
10
24
11
-
Depending on your installation method, the PHP interpreter will look for configuration files in locations described below.
25
+
Depending on your installation method, FrankenPHP and the PHP interpreter will look for configuration files in locations described below.
12
26
13
27
## Docker
14
28
29
+
FrankenPHP:
30
+
31
+
-`/etc/frankenphp/Caddyfile`: the main configuration file
32
+
-`/etc/frankenphp/caddy.d/*.caddy`: additional configuration files that are loaded automatically
33
+
34
+
PHP:
35
+
15
36
-`php.ini`: `/usr/local/etc/php/php.ini` (no `php.ini` is provided by default)
- PHP extensions: cannot be loaded, bundle them in the binary itself
@@ -229,34 +263,6 @@ and otherwise forward the request to the worker matching the path pattern.
229
263
}
230
264
```
231
265
232
-
### Full Duplex (HTTP/1)
233
-
234
-
When using HTTP/1.x, it may be desirable to enable full-duplex mode to allow writing a response before the entire body
235
-
has been read. (for example: WebSocket, Server-Sent Events, etc.)
236
-
237
-
This is an opt-in configuration that needs to be added to the global options in the `Caddyfile`:
238
-
239
-
```caddyfile
240
-
{
241
-
servers {
242
-
enable_full_duplex
243
-
}
244
-
}
245
-
```
246
-
247
-
> [!CAUTION]
248
-
>
249
-
> Enabling this option may cause old HTTP/1.x clients that don't support full-duplex to deadlock.
250
-
> This can also be configured using the `CADDY_GLOBAL_OPTIONS` environment config:
251
-
252
-
```sh
253
-
CADDY_GLOBAL_OPTIONS="servers {
254
-
enable_full_duplex
255
-
}"
256
-
```
257
-
258
-
You can find more information about this setting in the [Caddy documentation](https://caddyserver.com/docs/caddyfile/options#enable-full-duplex).
259
-
260
266
## Environment Variables
261
267
262
268
The following environment variables can be used to inject Caddy directives in the `Caddyfile` without modifying it:
@@ -293,6 +299,43 @@ You can also change the PHP configuration using the `php_ini` directive in the `
293
299
}
294
300
```
295
301
302
+
### Disabling HTTPS
303
+
304
+
By default, FrankenPHP will automatically enable HTTPS using for all the hostnames, including `localhost`.
305
+
If you want to disable HTTPS (for example in a development environment), you can set the `SERVER_NAME` environment variable to `http://` or `:80`:
306
+
307
+
Alternatively, you can use all other methods described in the [Caddy documentation](https://caddyserver.com/docs/automatic-https#activation).
308
+
309
+
If you want to use HTTPS with the `127.0.0.1` IP address instead of the `localhost` hostname, please read the [known issues](known-issues.md#using-https127001-with-docker) section.
310
+
311
+
### Full Duplex (HTTP/1)
312
+
313
+
When using HTTP/1.x, it may be desirable to enable full-duplex mode to allow writing a response before the entire body
314
+
has been read. (for example: [Mercure](mercure.md), WebSocket, Server-Sent Events, etc.)
315
+
316
+
This is an opt-in configuration that needs to be added to the global options in the `Caddyfile`:
317
+
318
+
```caddyfile
319
+
{
320
+
servers {
321
+
enable_full_duplex
322
+
}
323
+
}
324
+
```
325
+
326
+
> [!CAUTION]
327
+
>
328
+
> Enabling this option may cause old HTTP/1.x clients that don't support full-duplex to deadlock.
329
+
> This can also be configured using the `CADDY_GLOBAL_OPTIONS` environment config:
330
+
331
+
```sh
332
+
CADDY_GLOBAL_OPTIONS="servers {
333
+
enable_full_duplex
334
+
}"
335
+
```
336
+
337
+
You can find more information about this setting in the [Caddy documentation](https://caddyserver.com/docs/caddyfile/options#enable-full-duplex).
338
+
296
339
## Enable the Debug Mode
297
340
298
341
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/docker.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# Building Custom Docker Image
2
2
3
-
[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 variants are provided for popular architectures. Debian variants are recommended.
3
+
[FrankenPHP Docker images](https://hub.docker.com/r/dunglas/frankenphp) are based on [official PHP images](https://hub.docker.com/_/php/).
4
+
Debian and Alpine Linux variants are provided for popular architectures.
5
+
Debian variants are recommended.
4
6
5
7
Variants for PHP 8.2, 8.3 and 8.4 are provided.
6
8
@@ -28,6 +30,11 @@ docker build -t my-php-app .
28
30
docker run -it --rm --name my-running-app my-php-app
29
31
```
30
32
33
+
## How to Tweak the Configuration
34
+
35
+
For convenience, [a default `Caddyfile`](https://github.com/php/frankenphp/blob/main/caddy/frankenphp/Caddyfile) containing
36
+
useful environment variables is provided in the image.
37
+
31
38
## How to Install More PHP Extensions
32
39
33
40
The [`docker-php-extension-installer`](https://github.com/mlocati/docker-php-extension-installer) script is provided in the base image.
Copy file name to clipboardExpand all lines: docs/extensions.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ As covered in the manual implementation section below as well, you need to [get
33
33
The first step to writing a PHP extension in Go is to create a new Go module. You can use the following command for this:
34
34
35
35
```console
36
-
go mod init example.com/example
36
+
go mod init example.com/example
37
37
```
38
38
39
39
The second step is to [get the PHP sources](https://www.php.net/downloads.php) for the next steps. Once you have them, decompress them into the directory of your choice, not inside your Go module:
@@ -49,7 +49,7 @@ Everything is now setup to write your native function in Go. Create a new file n
|[ext-openssl](https://www.php.net/manual/en/book.openssl.php)| When using a static build of FrankenPHP (built with the musl libc), the OpenSSL extension may crash under heavy loads. A workaround is to use a dynamically linked build (like the one used in Docker images). This bug is [being tracked by PHP](https://github.com/php/php-src/issues/13648). |
|[ext-openssl](https://www.php.net/manual/en/book.openssl.php)| When using musl libc, the OpenSSL extension may crash under heavy loads. The problem doesn't occur when using the more popular GNU libc. This bug is [being tracked by PHP](https://github.com/php/php-src/issues/13648). |
19
19
20
20
## get_browser
21
21
22
22
The [get_browser()](https://www.php.net/manual/en/function.get-browser.php) function seems to perform badly after a while. A workaround is to cache (e.g. with [APCu](https://www.php.net/manual/en/book.apcu.php)) the results per User Agent, as they are static.
23
23
24
24
## Standalone Binary and Alpine-based Docker Images
25
25
26
-
The standalone binary and Alpine-based Docker images (`dunglas/frankenphp:*-alpine`) use [musl libc](https://musl.libc.org/) instead of [glibc and friends](https://www.etalabs.net/compare_libcs.html), to keep a smaller binary size. This may lead to some compatibility issues. In particular, the glob flag `GLOB_BRACE` is [not available](https://www.php.net/manual/en/function.glob.php)
26
+
The fully binary and Alpine-based Docker images (`dunglas/frankenphp:*-alpine`) use [musl libc](https://musl.libc.org/) instead of [glibc and friends](https://www.etalabs.net/compare_libcs.html), to keep a smaller binary size.
27
+
This may lead to some compatibility issues.
28
+
In particular, the glob flag `GLOB_BRACE` is [not available](https://www.php.net/manual/en/function.glob.php)
29
+
30
+
Prefer using the GNU variant of the static binary and Debian-based Docker images if you encounter issues.
Copy file name to clipboardExpand all lines: docs/laravel.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,8 @@ The `octane:frankenphp` command can take the following options:
76
76
> [!TIP]
77
77
> To get structured JSON logs (useful when using log analytics solutions), explicitly the pass `--log-level` option.
78
78
79
+
See also [how to use Mercure with Octane](#mercure-support).
80
+
79
81
Learn more about [Laravel Octane in its official documentation](https://laravel.com/docs/octane).
80
82
81
83
## Laravel Apps As Standalone Binaries
@@ -166,6 +168,34 @@ This is not suitable for embedded applications, as each new version will be extr
166
168
167
169
Set the `LARAVEL_STORAGE_PATH` environment variable (for example, in your `.env` file) or call the `Illuminate\Foundation\Application::useStoragePath()` method to use a directory outside the temporary directory.
168
170
171
+
### Mercure Support
172
+
173
+
[Mercure](https://mercure.rocks) is a great way to add real-time capabilities to your Laravel apps.
174
+
FrankenPHP includes [Mercure support out of the box](mercure.md).
175
+
176
+
If you are not using [Octane](#laravel-octane), see [the Mercure documentation entry](mercure.md).
177
+
178
+
If you are using Octane, you can use enable Mercure support by adding the following lines to your `config/octane.php` file:
You can use [all directives supported by Mercure](https://mercure.rocks/docs/hub/config#directives) in this array.
195
+
196
+
To publish and subscribe to updates, we recommend using the [Laravel Mercure Broadcaster](https://github.com/mvanduijker/laravel-mercure-broadcaster) library.
197
+
Alternatively, see [the Mercure documentation](mercure.md) to do it in pure PHP and JavaScript.
198
+
169
199
### Running Octane With Standalone Binaries
170
200
171
201
It's even possible to package Laravel Octane apps as standalone binaries!
0 commit comments