Serving a Laravel web application with FrankenPHP is as easy as mounting the project in the /app
directory of the official Docker image.
Run this command from the main directory of your Laravel app:
docker run -p 80:80 -p 443:443 -p 443:443/udp -v $PWD:/app dunglas/frankenphp
And enjoy!
Alternatively, you can run your Laravel projects with FrankenPHP from your local machine:
Add the following configuration to a file named Caddyfile
in the root directory of your Laravel project:
{
frankenphp
order php_server before file_server
}
# The domain name of your server
localhost {
# Set the webroot to the public/ dir
root * public/
# Enable compression (optional)
encode zstd br gzip
# Execute PHP files in the current directory and serve assets
php_server
}
Start FrankenPHP from the root directory of your Laravel project: ./frankenphp run
Octane may be installed via the Composer package manager:
composer require laravel/octane
After installing Octane, you may execute the octane:install
Artisan command, which will install Octane's configuration file into your application:
php artisan octane:install --server=frankenphp
The Octane server can be started via the octane:start
Artisan command.
php artisan octane:start
The octane:start
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--https
: Enable HTTPS, HTTP/2, and HTTP/3, and automatically generate and renew certificates--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 levelLearn more about Laravel Octane in its official documentation.