FrankenPHP: A Modern PHP App Server in Go (Install + Use)

Linux TLDR
Last Updated:
Reading time: 3 minutes

FrankenPHP is a modern PHP app server built on Go and using the Caddy server under the hood. The standout feature that caught my eye was its standalone and self-contained binary, which can be easily downloaded and used without requiring any installation.

In a single binary file, it aims to provide you with a PHP app server, a Caddy server, popular PHP extensions, native support for HTTP/1.1, HTTP/2, and HTTP/3, and much more that can truly enhance the experience, allowing developers to easily develop portable applications or quickly deploy their PHP applications to production.

Itโ€™s truly a modern PHP app server, and weโ€™ll discuss more about its features, installation, and usage in this article, so read it till the end.

Tutorial Details

DescriptionFrankenPHP: A Modern PHP App Server in Go
Difficulty LevelLow
Root or Sudo PrivilegesYes
OS CompatibilityLinux, Windows, and macOS
Prerequisitesโ€“
Internet RequiredYes (for installation)

Features of FrankenPHP

The following is a list of features that truly set it apart from its competitors.

  • A standalone, self-executable, dependency-free binary file built using Go and C.
  • It doesnโ€™t rely on PHP-FPM; instead, it uses its own SAPI, specially crafted for Go web servers.
  • It is 3.5x faster than FPM, according to their benchmarks, and improves website load times by 30%.
  • It is wrapped with the latest PHP 8, popular PHP extensions, (automatic HTTPS, HTTP/3, Brotli compression, etc.) powered by Caddy.
  • It provides native support for Symfony, API Platform, and Laravel.
  • Once launched, the application is stored in memory and handles incoming requests in milliseconds.
  • It offers a defined format and a specialized logging mechanism.
  • It automatically generates, renews, and revokes HTTPS certificates.

How to Install FrankenPHP on Linux

First of all, it doesnโ€™t require any installation; you can either use a Docker or directly download the standalone binary file from the project release page for Linux and macOS, give it executable permission, and then run it like a shell script with root or sudo privileges.

๐Ÿ“
When using HTTPS, ensure to visit โ€œhttps://localhostโ€ instead of โ€œhttps://127.0.0.1โ€ to accept the self-signed certificate.
#With Docker
$ docker run -v $PWD:/app/public -p 80:80 -p 443:443 -p 443:443/udp dunglas/frankenphp

#With a Standalone Binary File
$ chmod +x frankenphp                                                         #First, Give it a Executable Permission.
$ sudo ./frankenphp php-server                                           #Serve the Content of the Current Directory.
#OR
$ sudo ./frankenphp php-cli /path/to/your/script.php    #Serve the Content of the Assigned Script in CLI.

How to Use FrankenPHP

The usage is pretty simple; to serve your PHP file, simply place the FrankenPHP binary file in the same directory and execute the following command:

๐Ÿ“
Specify the โ€œ--workerโ€ option to serve the content of the current directory using a worker and the โ€œ-aโ€ option to access the log.
$ sudo ./frankenphp php-server

Output:

serving a directory using frankenphp

To execute a PHP script file in your terminal, specify the following command with the path to the PHP script file as an argument:

$ sudo ./frankenphp php-cli /var/www/html/index.php

Output:

executing php script using frankenphp

Most libraries require the HTTPS protocol to function. Therefore, to serve your PHP page using the HTTPS protocol, you can use the following command:

๐Ÿ“
Itโ€™s not recommended to use this approach in production as the certificate is self-signed.
$ sudo ./frankenphp php-server -d localhost

Output:

server php file in https protocol in frankenphp

To share your file locally or remotely via the file server, use the FrankenPHP built-in file server with a beautiful UI using the following command:

$ sudo ./frankenphp file-server                                                        #Start the file server.
#OR
$ sudo ./frankenphp file-server -b                                                   #Serve the Current Directory.
#OR
$ sudo ./frankenphp file-server -b -d localhost                             #Serve the Files in HTTPS protocol.

Output:

starting file server in frankenphp

Lastly, there are many ways to use FrankenPHP, but the article will become too long. Instead, I suggest checking out the following table for other command usages with their descriptions.

CommandDescription
sudo ./frankenphp environPrint the environment variables.
sudo ./frankenphp list-modulesLists the installed Caddy modules.
sudo ./frankenphp remove-package Removes Caddy packages.
sudo ./frankenphp trustInstalls a CA certificate in local trust stores.
sudo ./frankenphp upgradeUpgrade Caddy.

Also, check out the documentation page for information about various configuration settings.

Final Word

I hope you find this article useful, and if you want to know more about FrankenPHP, then do let me know in the comments, as I eagerly await your responses.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.

2 thoughts on โ€œFrankenPHP: A Modern PHP App Server in Go (Install + Use)โ€

  1. Arch Linux php-fpm package size: 3MB
    frankenphp package size 113 MB

    I stopped there. Clearly too much complexity under the hood.
    Thanks for the article.

    Reply
    • you should have carried on reading.
      you can not compare a self-contained binary package like frankenphp with just php-fpm package from arch.
      is basically a single file that contains everything an application needs to run. This includes the programโ€™s code itself (the executable), along with any libraries or other dependencies it relies on.

      Hereโ€™s a breakdown of the key features:

      Single File: The entire application is bundled into one executable file, making it easy to distribute and use.
      No External Dependencies: Unlike regular applications, self-contained ones donโ€™t require users to have specific libraries or software pre-installed on their system. Everything it needs is packed within the single file.
      Portability: Because they are self-contained, these packages can be run on any system that supports the binary format, regardless of the specific libraries or configurations present.

      moreover FrankenPHP contain a webserver +php + the glue
      your package Arch Linux php-fpm does not contain php by itself it need also to install it and more you should take into account itโ€™s dependencies and the dependencies of the dependencies.

      Reply