A PHP image packages the PHP runtime (Zend Engine), SAPI binaries (FPM, CLI), core extensions (PDO, mbstring, openssl), configuration files (php.ini, opcache settings) and commonly required system libraries; Composer is often available in build variants for dependency installation.
In containerized production it is typically run as PHP-FPM behind a web proxy or as a CLI worker for queues and scheduled jobs; teams layer application code and environment-specific config on top and rely on the image for consistent runtime behavior across deployments.
Teams evaluate a PHP hardened image in secure or regulated environments to reduce attack surface and improve auditability: hardened builds remove compilers and unnecessary packages, enforce non-root execution, restrict enabled PHP functions, apply timely CVE patches, and provide reproducible, signed artifacts for compliance.
The Minimus PHP image differs from typical PHP container images by being built from scratch with only the essential components—runtime, required extensions and minimal init—rather than layering a full OS distribution and package manager. That design yields a reduced attack surface and produces an image that is faster, lighter, and easier to maintain for engineers who need predictable, minimal runtime environments.
Beyond size and composition, Minimus images are hardened to industry standards like NIST SP 800-190 and CIS Benchmarks; the Minimus hardened PHP image applies secure defaults, tightened filesystem permissions, runtime hardening and minimized tooling to simplify compliance reviews and reduce operational risk. This focused hardening streamlines maintenance and makes security controls more transparent for security-focused teams.
In container terms, a runtime container image for PHP packages the PHP interpreter with a web server and common extensions, enabling quick deployment of PHP applications.
For production, consider a hardened PHP image to minimize surface area, reduce privileges, and keep dependencies lean.
FROM php:8.1-apache
COPY src/ /var/www/html/
To display an image in PHP, embed an HTML <img> tag referencing the file or URL, or serve the image via a PHP script with the proper Content-Type.
Example:
<img src="images/photo.jpg" alt="Photo">
PHP script to serve image directly:
<?php
$path = 'images/photo.jpg';
header('Content-Type: image/jpeg');
readfile($path);
?>
For production, consider using a hardened PHP image.
A PHP file is plain text with a .php extension. It may embed HTML and contain PHP blocks that run on the server. The server processes the PHP code and returns HTML to the client. In a container workflow, you might run code inside a hardened PHP image.
Example:
<?php
echo "Hello, world!";
?>
Notes: In production, configure PHP securely, disable error reporting, and run in a minimal, updated container image.