
In my previous article, Boost Laravel Performance: Running Octane with FrankenPHP in Production (Zero Downtime), I demonstrated a great solution, but some key details were missing. Specifically:
If you’re looking for answers to these questions, let’s cover them in this article.
PHP_EXTENSIONS Docker ARG.For instance, run the following command to only build the redis extension:
docker buildx bake \
--load \
--set static-builder.args.PHP_EXTENSIONS=redis \
static-builderTo add libraries enabling additional functionality to the extensions you’ve enabled, you can pass use the PHP_EXTENSION_LIBS Docker ARG:
docker buildx bake \
--load \
--set static-builder.args.PHP_EXTENSIONS=redis \
--set static-builder.args.PHP_EXTENSION_LIBS=libjpeg,libwebp \
static-builderstatic-php under the hood to compile PHP binary here is the list https://static-php.dev/en/guide/extensions.htmlphp.ini settingsini_set() and set_time_limit() functions. For example:ini_set('memory_limit', '256M');
set_time_limit(60); // Limit script execution to 60 secondsThis approach lets you adjust settings such as memory limits and execution time without affecting the global configuration, providing flexibility in how your PHP scripts run.
docker buildx bake \
--load \
--set static-builder.args.PHP_EXTENSIONS=redis \
--set static-builder.args.PHP_EXTENSION_LIBS=libjpeg,libwebp \
--set static-builder.args. PHP_VERSION=8.0 \
static-builderdocker cp $(docker create --name static-builder dunglas/frankenphp:static-builder):/go/src/app/dist/frankenphp-linux-$(uname -m) frankenphp ; docker rm static-builderCustomize FrankenPHP allows you to optimize your Laravel applications effectively. By adjusting PHP extensions, changing settings, and managing PHP versions, you can create a tailored environment that meets your application’s needs. These enhancements can significantly improve performance and flexibility, ensuring a smooth deployment process.
For more information about FrankenPHP, check out the FrankenPHP documentation.
Yes, you can add custom extensions by compiling them yourself. Refer to the static-php documentation for guidance on adding unsupported extensions.
The best PHP version depends on your application requirements and compatibility with Laravel. It’s generally recommended to use the latest stable version supported by your Laravel version.
Yes, you can change PHP settings dynamically using ini_set() in your PHP scripts. However, be cautious when adjusting critical settings on a live server.