No description
  • Dockerfile 82.1%
  • PHP 17.9%
Find a file
2026-05-07 16:41:04 +00:00
public init setup php with Dockerfile and compose 2026-03-27 16:16:59 +00:00
compose.yaml Update compose.yaml 2026-05-07 16:41:04 +00:00
Dockerfile init setup php with Dockerfile and compose 2026-03-27 16:16:59 +00:00
README.md docs: add comprehensive README with Dockerfile/compose.yaml documentation 2026-03-27 23:04:42 +00:00

PHP Docker Environment

A Docker-based PHP development environment using FrankenPHP (a modern PHP server that combines Nginx and PHP-FPM into a single process) with Traefik reverse proxy integration.

Project Structure

php-docker/
├── Dockerfile          # PHP container configuration
├── compose.yaml        # Docker Compose service definition
├── README.md           # This file
└── public/
    └── index.php       # Default PHP entry point

Components

Dockerfile

The Dockerfile is based on serversideup/php:8.5-frankenphp, which provides:

  • PHP 8.5 - The latest PHP version
  • FrankenPHP - A modern PHP server that integrates Nginx and PHP-FPM
  • Pre-installed extensions - Ready for PHP development

Customizations:

  • Installs the intl and bcmath PHP extensions
  • Runs as www-data user for security

compose.yaml

The compose.yaml defines a single service:

Feature Configuration
Service Name php
Port localhost:8080container:8080
Volume Mount Current directory → /var/www/html
Network proxy (Traefik integration)

Traefik Labels

The service is configured for Traefik reverse proxy with:

  • HTTP Router: php.apps.actionbehind.com (port 80)
  • HTTPS Router: php.apps.actionbehind.com (port 443)
  • HTTPS Redirect: Automatic redirect from HTTP to HTTPS
  • SSL Certificate: Let's Encrypt certificate resolution

Prerequisites

Usage Instructions

Quick Start

  1. Start the container:

    docker compose up -d
    
  2. Access the application:

  3. View logs:

    docker compose logs -f
    

Development

  1. Place your PHP files in the public/ directory - This is the web root (/var/www/html)

  2. Edit files locally - Changes are immediately reflected via volume mounting

  3. Restart container after dependency changes:

    docker compose up -d --build
    

Available PHP Extensions

The following extensions are pre-installed:

  • intl - Internationalization functions
  • bcmath - Arbitrary precision mathematics

Common Commands

Command Description
docker compose up -d Start containers in background
docker compose down Stop and remove containers
docker compose down -v Stop, remove containers AND volumes
docker compose logs -f Follow container logs
docker compose exec php php -v Run PHP inside container
docker compose exec php bash Get shell access to container

Traefik Configuration Notes

The Traefik labels configure:

  1. redirect-to-https@file - A Traefik middleware that redirects HTTP to HTTPS
  2. certresolver=letsencrypt - Uses Let's Encrypt for SSL certificates
  3. Host rule - Routes requests to php.apps.actionbehind.com to this service

If you're running locally without Traefik, you can access the service at http://localhost:8080 and ignore the Traefik labels.

Customization

To add more PHP extensions, modify the Dockerfile:

RUN install-php-extensions extension_name

To change the PHP version, update the base image:

FROM serversideup/php:8.2-frankenphp  # or 8.3, 8.4

To modify Traefik configuration, update the labels section in compose.yaml.