Skip to content

Commit

Permalink
docs: customizing the configuration (dunglas#911)
Browse files Browse the repository at this point in the history
* docs: customizing the configuration

* Update docs/config.md

Co-authored-by: Jacob Dreesen <[email protected]>

* Update docs/fr/config.md

Co-authored-by: Jacob Dreesen <[email protected]>

* Update embed.md

---------

Co-authored-by: Jacob Dreesen <[email protected]>
  • Loading branch information
dunglas and jdreesen authored Jul 9, 2024
1 parent 0500ebc commit e743f6a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
7 changes: 5 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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).

In the Docker image, the `Caddyfile` is located at `/etc/caddy/Caddyfile`.
In [the Docker images](docker.md), 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 manually or copy an official template:
In the Docker images, the `php.ini` file is not present, you can create it manually or copy an official template:

```dockerfile
FROM dunglas/frankenphp
Expand All @@ -18,6 +18,9 @@ RUN cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
```

The static binary will look for a `php.ini` file in the current working directory,
in `/usr/local/lib/` as well as [the other standard locations](https://www.php.net/manual/en/configuration.file.php).

## Caddyfile Config

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.
Expand Down
13 changes: 9 additions & 4 deletions docs/embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

FrankenPHP has the ability to embed the source code and assets of PHP applications in a static, self-contained binary.

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.
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 2023](https://dunglas.dev/2023/12/php-and-symfony-apps-as-standalone-binaries/).

Expand All @@ -12,12 +12,12 @@ For embedding Laravel applications, [read this specific documentation entry](lar

Before creating the self-contained binary be sure that your app is ready for embedding.

For instance you likely want to:
For instance, you likely want to:

* Install the production dependencies of the app
* Dump the autoloader
* Enable the production mode of your application (if any)
* Strip uneeded files such as `.git` or tests to reduce the size of your final binary
* Strip unneeded files such as `.git` or tests to reduce the size of your final binary

For instance, for a Symfony app, you can use the following commands:

Expand All @@ -42,6 +42,11 @@ composer install --ignore-platform-reqs --no-dev -a
composer dump-env prod
```

### Customizing the Configuration

To customize [the configuration](config.md), you can put a `Caddyfile` as well as a `php.ini` file
in the main directory of the app to be embedded (`$TMPDIR/my-prepared-app` in the previous example).

## Creating a Linux Binary

The easiest way to create a Linux binary is to use the Docker-based builder we provide.
Expand Down Expand Up @@ -107,7 +112,7 @@ If your app contains a [worker script](worker.md), start the worker with somethi
./my-app php-server --worker public/index.php
```
To enable HTTPS (a Let's Encrypt certificate is automatically created), HTTP/2 and HTTP/3, specify the domain name to use:
To enable HTTPS (a Let's Encrypt certificate is automatically created), HTTP/2, and HTTP/3, specify the domain name to use:

```console
./my-app php-server --domain localhost
Expand Down
3 changes: 3 additions & 0 deletions docs/fr/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ RUN cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
```

Le binaire statique cherchera un fichier `php.ini` dans le répertoire de travail courant,
dans `/usr/local/lib/` ainsi que [les autres emplacements standards](https://www.php.net/manual/fr/configuration.file.php).

## Configuration du Caddyfile

Pour enregistrer l'exécutable de FrankenPHP, l'[option globale](https://caddyserver.com/docs/caddyfile/concepts#global-options) `frankenphp` doit être définie, puis les [directives HTTP](https://caddyserver.com/docs/caddyfile/concepts#directives) `php_server` ou `php` peuvent être utilisées dans les blocs de site pour servir votre application PHP.
Expand Down
7 changes: 7 additions & 0 deletions docs/fr/embed.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ composer install --ignore-platform-reqs --no-dev -a
composer dump-env prod
```

### Personnaliser la configuration

Pour personnaliser [la configuration](config.md),
vous pouvez mettre un fichier `Caddyfile` ainsi qu'un fichier `php.ini`
dans le répertoire principal de l'application à intégrer
(`$TMPDIR/my-prepared-app` dans l'exemple précédent).

## Créer un binaire Linux

La manière la plus simple de créer un binaire Linux est d'utiliser le builder basé sur Docker que nous fournissons.
Expand Down

0 comments on commit e743f6a

Please sign in to comment.