DEV Community

Cover image for Using Frankenphp with Laravel Octane
fajar sp
fajar sp

Posted on

1

Using Frankenphp with Laravel Octane

The Original Post is here

in your existing laravel app, install laravel octane using this command

composer require laravel/octane
php artisan octane:install --server=frankenphp
Enter fullscreen mode Exit fullscreen mode

adjust env variable OCTANE_SERVER=frankenphp

run frankenphp with this command:

php artisan octane:frankenphp
Enter fullscreen mode Exit fullscreen mode

The octane:frankenphp command can take the following options:

  • --host: The IP address the server should bind to (default: 127.0.0.1)
  • --port: The port the server should be available on (default: 8000)
  • --admin-port: The port the admin server should be available on (default: 2019)
  • --workers: The number of workers that should be available to handle requests (default: auto)
  • --max-requests: The number of requests to process before reloading the server (default: 500)
  • --caddyfile: The path to the FrankenPHP Caddyfile file (default: stubbed Caddyfile in Laravel Octane)
  • --https: Enable HTTPS, HTTP/2, and HTTP/3, and automatically generate and renew certificates
  • --http-redirect: Enable HTTP to HTTPS redirection (only enabled if –https is passed)
  • --watch: Automatically reload the server when the application is modified
  • --poll: Use file system polling while watching in order to watch files over a network
  • --log-level: Log messages at or above the specified log level, using the native Caddy logger

for deployment let's create aDockerfile

i use php 8.2 and postgres database so i need to install pgsql php
extension

FROM dunglas/frankenphp:latest-php8.2

# Install dependencies untuk Composer dan ekstensi PHP
RUN apt-get update && apt-get install -y \
    curl \
    unzip \
    libpq-dev \
    libexif-dev \
    libsodium-dev

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN install-php-extensions \
    pgsql \
    pdo_pgsql \
    gd \
    intl \
    zip \
    exif \
    sodium \
    pcntl

WORKDIR /app

COPY . ./

# Install dependencies using Composer
RUN composer install --no-dev --optimize-autoloader

RUN rm -rf ./git

# Run FrankenPHP
CMD ["php", "artisan", "octane:frankenphp", "--host=0.0.0.0", "--port=80", "--admin-port=2019"]
Enter fullscreen mode Exit fullscreen mode

lets build this image using

docker build -t app:latest .
Enter fullscreen mode Exit fullscreen mode

lets create a docker-compose.yml file

services:
    app:
        image: "app:latest"
        restart: unless-stopped
        volumes:
          - ./.env:/app/.env
Enter fullscreen mode Exit fullscreen mode

run it using

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

my use case

i use frankenphp in my personal site using laravel and filamentphp for frontend and
admin panel at https://fajar.labkita.my.id, the
speed is amazing :)

pagespeed1

pagespeed2

Reference

Canonical URL
For more detailed information, visit the original post on my blog.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more