Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dunglas/frankenphp-demo
Demo app for FrankenPHP
https://github.com/dunglas/frankenphp-demo
api-platform frankenphp golang php symfony
Last synced: 2 days ago
JSON representation
Demo app for FrankenPHP
- Host: GitHub
- URL: https://github.com/dunglas/frankenphp-demo
- Owner: dunglas
- Created: 2022-10-14T10:34:16.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-02T21:16:08.000Z (6 months ago)
- Last Synced: 2024-12-14T07:07:00.863Z (9 days ago)
- Topics: api-platform, frankenphp, golang, php, symfony
- Language: HTML
- Homepage: https://frankenphp.dev
- Size: 151 KB
- Stars: 158
- Watchers: 5
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FrankenPHP Demo
A demo app using [FrankenPHP](https://frankenphp.dev) that uses
Symfony and API Platform.## Installation
### Composer
Install composer dependencies:
```console
docker run --rm -it -v $PWD:/app composer:latest install
```Or if you have composer installed locally:
```console
composer install
```### The project
Run the project with Docker (worker mode):
```console
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](https://github.com/dunglas/frankenphp/blob/main/docs/compile.md)
by yourself.Create the database (It uses a local SQLite database stored in `var/data.db`):
```console
docker exec -it FrankenPHP-demo php bin/console doctrine:migrations:migrate --no-interaction
```Then you can access the application:
* [Hello world page](https://localhost)
* [API Platform](https://localhost/api)
* [API Platform: collection of monsters (GET/JSON-LD)](https://localhost/api/monsters.jsonld)This demo is a standard Symfony application and works without FrankenPHP.
Therefore, you can serve it with the Symfony CLI:```console
symfony serve
```The repository also includes [a benchmark](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`:
```console
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:```console
chmod +x ./frankenphp-demo
./frankenphp-demo php-server
```It's also possible to run commands with `./frankenphp-demo php-cli bin/console`.