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
Description | FrankenPHP: A Modern PHP App Server in Go |
Difficulty Level | Low |
Root or Sudo Privileges | Yes |
OS Compatibility | Linux, Windows, and macOS |
Prerequisites | โ |
Internet Required | Yes (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.
#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:
--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:
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:
Most libraries require the HTTPS protocol to function. Therefore, to serve your PHP page using the HTTPS protocol, you can use the following command:
$ sudo ./frankenphp php-server -d localhost
Output:
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:
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.
Command | Description |
---|---|
sudo ./frankenphp environ | Print the environment variables. |
sudo ./frankenphp list-modules | Lists the installed Caddy modules. |
sudo ./frankenphp remove-package | Removes Caddy packages. |
sudo ./frankenphp trust | Installs a CA certificate in local trust stores. |
sudo ./frankenphp upgrade | Upgrade 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!
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.
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.