Skip to content

dunglas/frankenphp-demo

Folders and files

NameName
Last commit message
Last commit date
Oct 14, 2022
Oct 30, 2021
Feb 23, 2024
Oct 27, 2022
Feb 26, 2024
Oct 15, 2022
Aug 19, 2023
Aug 19, 2023
Oct 30, 2021
Feb 26, 2024
Jun 27, 2024
Feb 26, 2024
Jun 27, 2024
Dec 6, 2023
Feb 26, 2024

Repository files navigation

FrankenPHP Demo

A demo app using FrankenPHP that uses Symfony and API Platform.

Installation

Composer

Install composer dependencies:

docker run --rm -it -v $PWD:/app composer:latest install

Or if you have composer installed locally:

composer install

The project

Run the project with Docker (worker mode):

docker run \
    -e FRANKENPHP_CONFIG="worker ./public/index.php" \
    -v $PWD:/app \
    -p 80:80 -p 443:443/tcp -p 443:443/udp \
    --name FrankenPHP-demo \
    dunglas/frankenphp

PS: Docker is optional; you can also compile FrankenPHP by yourself.

Create the database (It uses a local SQLite database stored in var/data.db):

docker exec -it FrankenPHP-demo php bin/console doctrine:migrations:migrate --no-interaction

Then you can access the application:

This demo is a standard Symfony application and works without FrankenPHP. Therefore, you can serve it with the Symfony CLI:

symfony serve

The repository also includes a benchmark comparing FrankenPHP and PHP-FPM.

Package as a Standalone Binary

The demo app can be packaged as a self-contained binary containing the Symfony app, FrankenPHP and the PHP extensions used by the app.

To do so, the easiest way is to use the provided Dockerfile:

docker build -t static-app -f static-build.Dockerfile .
docker cp $(docker create --name static-app-tmp static-app):/go/src/app/dist/frankenphp-linux-x86_64 frankenphp-demo ; docker rm static-app-tmp

The resulting binary is the frankenphp-demo file in the current directory. It can be started with the following commands:

chmod +x ./frankenphp-demo
./frankenphp-demo php-server

It's also possible to run commands with ./frankenphp-demo php-cli bin/console.