Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Caddyfile config adjustments #345

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini; \
sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/' $PHP_INI_DIR/php.ini;
```

## Caddy Directives
## Caddyfile Config

To register the FrankenPHP executor, the `frankenphp` directive must be set in Caddy global options, then the `php_server` or the `php` HTTP directives must be set under routes serving PHP scripts.
To register the FrankenPHP executor, the `frankenphp` [global option](https://caddyserver.com/docs/caddyfile/concepts#global-options) must be set, then the `php_server` or the `php` [HTTP directives](https://caddyserver.com/docs/caddyfile/concepts#directives) may be used within the site blocks to serve your PHP app.

Minimal example:

Expand All @@ -39,7 +39,7 @@ localhost {
}
```

Optionally, the number of threads to create and [worker scripts](worker.md) to start with the server can be specified under the global directive.
Optionally, the number of threads to create and [worker scripts](worker.md) to start with the server can be specified under the global option.

```caddyfile
{
Expand All @@ -56,7 +56,7 @@ Optionally, the number of threads to create and [worker scripts](worker.md) to s
# ...
```

Alternatively, the short form of the `worker` directive can also be used:
Alternatively, you may use the one-line short form of the `worker` option:

```caddyfile
{
Expand All @@ -79,12 +79,13 @@ You can also define multiple workers if you serve multiple apps on the same serv
}

app.example.com {
root /path/to/app/public/
root * /path/to/app/public
php_server
}


other.example.com {
root /path/to/other/public/
root * /path/to/other/public
php_server
}
...
```
Expand All @@ -95,22 +96,24 @@ but if you need full control, you can use the lower level `php` directive:
Using the `php_server` directive is equivalent to this configuration:

```caddyfile
# Add trailing slash for directory requests
@canonicalPath {
file {path}/index.php
not path */
}
redir @canonicalPath {path}/ 308
# If the requested file does not exist, try index files
@indexFiles file {
try_files {path} {path}/index.php index.php
split_path .php
route {
# Add trailing slash for directory requests
@canonicalPath {
file {path}/index.php
not path */
}
redir @canonicalPath {path}/ 308
# If the requested file does not exist, try index files
@indexFiles file {
try_files {path} {path}/index.php index.php
split_path .php
}
rewrite @indexFiles {http.matchers.file.relative}
# FrankenPHP!
@phpFiles path *.php
php @phpFiles
file_server
}
rewrite @indexFiles {http.matchers.file.relative}
# FrankenPHP!
@phpFiles path *.php
php @phpFiles
file_server
```

The `php_server` and the `php` directives have the following options:
Expand Down
2 changes: 2 additions & 0 deletions docs/laravel.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Alternatively, you can run your Laravel projects with FrankenPHP from your local

# The domain name of your server
localhost {
# Set the webroot to the public/ dir
root * public/
# Enable compression (optional)
encode zstd gzip
# Execute PHP files in the current directory and serve assets
Expand Down
Loading