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

Adding documentation for FrankenPHP #829

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from
Open
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
70 changes: 70 additions & 0 deletions cookbook/web-server/franken-php.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FrankenPHP via Docker
=====================

To add FrankenPHP to an existing project you can follow these steps: `FrankenPHP Documentation`_.

However after running through those steps you need to modify the setup a slight bit:
1. Installing the correct php extensions
2. Adding a database to the project
3. Removing Sulu's default configuration

The modifications
-----------------

.. note::

Beware these instructions might get out of date if FrankenPHP Documentation changes.

After installing you should have a `Dockerfile` which is the base for all containers.

There should be a section under like this:

.. code-block:: dockerfile

# Base FrankenPHP image
...
RUN set -eux; \
install-php-extensions \
@composer \
apcu \
intl \
opcache \
zip \
;

This is the list of installed extensions. For Sulu you also need: `gd` and `pdo_mysql` or `pdo_postgres`.

Secondly we also need to add a database. We can just do that by adding it to the yaml configuration file `compose.yaml`.

Here is an example configuration for mysql:

.. code-block:: yaml

services:
# ....
database:
# arm compatible mysql docker image
image: mysql/mysql-server:${MYSQL_VERSION:-8.0} # arm and x86/x64 compatible mysql image
command: [ "--max_connections=1000", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_general_ci" ]
environment:
MYSQL_DATABASE: ${MYSQL_DATABASE:-sulu}
# You should definitely change the password in production
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-ChangeMe}
MYSQL_ROOT_HOST: '%'
volumes:
- db-data:/var/lib/mysql
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
# - ./docker/db/data:/var/lib/mysql:rw

After setting up the container you might also want to update the `DATABASE_URL` variable in the php service (by default it assumes postgres). At least note that FrankenPHP and the default Sulu mysql container have different default credentials.

If you have some other modifications in your set up be sure to copy all changes of the `docker-compose*` files to the `compose.yaml` and `compose.override.yaml`.

After all this, the Sulu default configuration is not used anymore and can be removed:

.. code-block:: bash

rm docker-compose.yaml
rm docker-compose.override.yaml

.. _FrankenPHP Documentation: https://github.com/dunglas/symfony-docker/blob/main/docs/existing-project.md#installing-on-an-existing-project
1 change: 1 addition & 0 deletions cookbook/web-server/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ these tools.
apache
nginx
built-in
franken-php
Loading