Giter Site home page Giter Site logo

dunglas / frankenphp-demo Goto Github PK

View Code? Open in Web Editor NEW
128.0 5.0 13.0 141 KB

Demo app for FrankenPHP

Home Page: https://frankenphp.dev

JavaScript 0.56% HTML 92.44% PHP 5.53% Twig 1.04% Dockerfile 0.44%
api-platform golang php symfony frankenphp

frankenphp-demo's Introduction

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.

frankenphp-demo's People

Contributors

chris53897 avatar coil avatar dunglas avatar husimo-tilleuls avatar nayte91 avatar paullallier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

frankenphp-demo's Issues

Can't run composer install

Hello,

It seems that since you added the frankenphp runtime in composer.json, I can't run composer install from README because composer is using PHP 8.1 and PHP 8.2 is needed.

    - Root composer.json requires php >=8.2 but your php version (8.1.11) does not satisfy that requirement.

So I built a custom composer image :

FROM php:8.2.0RC4
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

And now I have :

  Problem 1
    - laminas/laminas-code is locked to version 4.7.0 and an update of this package was not requested.
    - laminas/laminas-code 4.7.0 requires php >=7.4, <8.2 -> your php version (8.2.0RC4) does not satisfy that requirement.
  Problem 2
    - laminas/laminas-code 4.7.0 requires php >=7.4, <8.2 -> your php version (8.2.0RC4) does not satisfy that requirement.
    - friendsofphp/proxy-manager-lts v1.0.12 requires laminas/laminas-code ~3.4.1|^4.0 -> satisfiable by laminas/laminas-code[4.7.0].
    - friendsofphp/proxy-manager-lts is locked to version v1.0.12 and an update of this package was not requested

Well, laminas/laminas-code is not yet available to PHP 8.2.

So, is it a dead end ?

Thank you

can't use doctrine

I can't use doctrine mysql in app franken. Its normal because i haven't a extension in php.ini ? or others ?

`docker-compose exec frankenphp bin/console d:m:m

In ExceptionConverter.php line 117:

An exception occurred in the driver: could not find driver

In Exception.php line 28:

could not find driver

In Driver.php line 27:

could not find driver `

HTTP3 By default

Hello !

I tried your demo to see if frankenphp uses http3.

  • Cloned repo,
  • composer install,
  • docker run
    -e FRANKENPHP_CONFIG="worker ./public/index.php"
    -v $PWD:/app
    -p 80:80 -p 443:443
    dunglas/frankenphp
  • use firefox 121 (note that it handles H3, as I see h3 request/responses when downloading fonts for example)

And on my network tab, everything is H2.

I tried to add udp to actual command:

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

And same results.

Do you know if something must be activated somewhere? Do you share this observation?

Thank you for the good work!

Hosted benchmarks

Could we get the benchmarks as MD, or hosted? Github does not let you view html files.

unexpected termination, restarting

Running command from README in the repo cloned locally, I got the error:

{"level":"error","ts":1665759970.5398932,"msg":"unexpected termination, restarting","worker":"/app/public/index.php"}
{"level":"error","ts":1665759970.5401196,"msg":"unexpected termination, restarting","worker":"/app/public/index.php"}
{"level":"error","ts":1665759970.5425582,"msg":"unexpected termination, restarting","worker":"/app/public/index.php"}
{"level":"error","ts":1665759970.5429497,"msg":"unexpected termination, restarting","worker":"/app/public/index.php"}
{"level":"error","ts":1665759970.543217,"msg":"unexpected termination, restarting","worker":"/app/public/index.php"}

Seems that worker is in a restart loop

Auto SSL does not work correct for me

Mac M1.
A intermedia certificate gets created, but the browser (firefox and chrome tested), say that this is not a valid one.

The most import line in the log is probably server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS

{"level":"info","ts":1692474817.7516222,"msg":"maxprocs: Leaving GOMAXPROCS=2: CPU quota undefined"} {"level":"info","ts":1692474817.7724752,"msg":"using provided configuration","config_file":"/etc/Caddyfile","config_adapter":""} {"level":"warn","ts":1692474817.7732594,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/Caddyfile","line":3} {"level":"info","ts":1692474817.7738304,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]} {"level":"info","ts":1692474817.7739658,"logger":"http.auto_https","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443} {"level":"info","ts":1692474817.7739768,"logger":"http.auto_https","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"} {"level":"info","ts":1692474817.7741318,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x4000033a80"} {"level":"info","ts":1692474817.8361635,"msg":"FrankenPHP started ๐Ÿ˜","php_version":"8.2.9"} {"level":"info","ts":1692474817.8363905,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/root/.local/share/caddy"} {"level":"info","ts":1692474817.8364415,"logger":"tls","msg":"finished cleaning storage units"} {"level":"warn","ts":1692474817.8439717,"logger":"pki.ca.local","msg":"installing root certificate (you might be prompted for password)","path":"storage:pki/authorities/local/root.crt"} {"level":"info","ts":1692474817.8441658,"msg":"define JAVA_HOME environment variable to use the Java trust"} {"level":"info","ts":1692474817.8441718,"msg":"warning: \"certutil\" is not available, install \"certutil\" with \"apt install libnss3-tools\" or \"yum install nss-tools\" and try again"} {"level":"info","ts":1692474818.4005547,"msg":"certificate installed properly in linux trusts"} {"level":"info","ts":1692474818.4009395,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"} {"level":"info","ts":1692474818.401096,"msg":"failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes for details."} {"level":"info","ts":1692474818.4012878,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]} {"level":"info","ts":1692474818.4013226,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]} {"level":"info","ts":1692474818.4013844,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["localhost"]} {"level":"info","ts":1692474818.4015412,"msg":"autosaved config (load with --resume flag)","file":"/root/.config/caddy/autosave.json"} {"level":"info","ts":1692474818.4016128,"msg":"serving initial configuration"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.