Skip to content

wylouuu/xampp-docker

Repository files navigation

🐳 PHP Docker Service

A Modern XAMPP Alternative - Complete PHP Development Environment

Docker PHP MySQL Apache License

Built with ❤️ by Wylou | PT. Lunexia Tech Horizon

FeaturesQuick StartDocumentationContributing


📖 Overview

PHP Docker Service is a production-ready Docker Compose setup that provides a complete PHP development environment, similar to XAMPP but with modern containerization benefits. It includes Apache, PHP 8.3, MySQL 8.0, and phpMyAdmin - everything you need for PHP development in one command.

Why PHP Docker Service?

  • 🚀 One-Command Setup - Get started in seconds, not minutes
  • 🔄 Auto-Reload - Changes reflect immediately without manual refresh
  • 🐳 Docker-Based - Consistent environment across all machines
  • Production-Ready - Optimized for both development and production
  • 🎨 Framework Support - Works with Laravel, CodeIgniter, Symfony, and more
  • 🔧 Fully Configurable - Customize PHP, Apache, and MySQL settings easily
  • 📦 Pre-Installed Extensions - 20+ PHP extensions ready to use
  • 🔒 Isolated Environment - No conflicts with system PHP/MySQL

✨ Features

Core Services

  • PHP 8.3 with Apache (mod_php)
  • MySQL 8.0 with persistent data storage
  • phpMyAdmin for database management
  • Composer pre-installed for dependency management

Development Features

  • 🔄 Auto-Reload - JavaScript-based auto-refresh on file changes
  • ⏱️ Extended Timeouts - 10 minutes for long-running scripts
  • 💾 Large File Support - 256MB upload limit, 512MB memory
  • 🎯 Hot Reload - Changes reflect immediately (no restart needed)
  • 📝 Error Display - Development-friendly error reporting

PHP Extensions

Pre-installed and ready to use:

  • Database: pdo, pdo_mysql, mysqli
  • Image Processing: gd (with WebP, JPEG, PNG support)
  • String Handling: mbstring, xml, xsl
  • Compression: zip, bz2
  • Math: bcmath, gmp
  • Caching: opcache, redis, apcu
  • Internationalization: intl
  • And many more...

Framework Support

  • ✅ Laravel (full support)
  • ✅ CodeIgniter
  • ✅ Symfony
  • ✅ Slim Framework
  • ✅ Any PHP framework or vanilla PHP

Modern Web Technologies

  • ✅ CSS/SCSS support
  • ✅ JavaScript/jQuery
  • ✅ Tailwind CSS
  • ✅ Vue.js, React, Alpine.js
  • ✅ Bootstrap, Bulma, and other CSS frameworks

🚀 Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/wylou/php-service.git
    cd php-service
  2. Configure environment (optional)

    cp .env.example .env
    # Edit .env to customize ports and credentials
  3. Start the services

    docker-compose up -d --build
  4. Access your services

That's it! Your PHP development environment is ready. 🎉


📁 Project Structure

php-service/
├── docker/
│   ├── apache/
│   │   └── vhost.conf          # Apache virtual host configuration
│   ├── mysql/
│   │   └── init/               # SQL initialization scripts
│   └── php/
│       ├── Dockerfile          # Custom PHP 8.3 image
│       └── php.ini             # PHP configuration
├── logs/                       # Apache & MySQL logs
├── www/                        # 📂 Your PHP files go here!
│   ├── index.php               # Welcome page
│   ├── _auto-reload.js         # Auto-reload script
│   └── demo/                   # Demo files
├── .env                        # Environment variables
├── .env.example                # Example environment file
├── docker-compose.yml          # Docker Compose configuration
└── README.md                   # This file

🎯 Usage Examples

Basic PHP File

Create a file in www/ folder:

<?php
echo "Hello from PHP Docker Service!";
phpinfo();
?>

Access at: http://localhost:8080/your-file.php

Laravel Project

# Enter container
docker exec -it php-apache bash

# Create Laravel project
composer create-project laravel/laravel my-app

# Set permissions
chown -R www-data:www-data my-app
chmod -R 755 my-app/storage

Access at: http://localhost:8080/my-app/public/

Database Connection

<?php
$host = 'mysql';  // Use container name
$dbname = 'app_db';
$user = 'developer';
$pass = 'developer123';

$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
echo "Connected successfully!";
?>

Auto-Reload Setup

Include in your HTML:

<script src="/_auto-reload.js"></script>

Changes will auto-refresh in the browser! 🔄


⚙️ Configuration

Environment Variables

Edit .env file to customize:

# Web Server Ports
WEB_PORT=8080
WEB_PORT_ALT=8081

# MySQL Configuration
MYSQL_PORT=3306
MYSQL_ROOT_PASSWORD=your_secure_password
MYSQL_DATABASE=app_db
MYSQL_USER=developer
MYSQL_PASSWORD=your_password

# phpMyAdmin
PMA_PORT=8888

PHP Configuration

Edit docker/php/php.ini to customize PHP settings:

  • max_execution_time = 600 (10 minutes)
  • memory_limit = 512M
  • upload_max_filesize = 256M
  • post_max_size = 512M

Apache Configuration

Edit docker/apache/vhost.conf for Apache settings.


🔧 Common Commands

# Start services
docker-compose up -d

# Stop services
docker-compose down

# View logs
docker-compose logs -f

# Restart a service
docker-compose restart web

# Enter PHP container
docker exec -it php-apache bash

# Run Composer
docker exec -it php-apache composer install

# Check service status
docker-compose ps

📚 Documentation


🎨 Demo

Check out the demo page to see CSS, Tailwind, and jQuery in action:

Demo: http://localhost:8080/demo/css-demo.php


🐛 Troubleshooting

Port Already in Use

Change ports in .env:

WEB_PORT=8082
PMA_PORT=8890

Permission Issues

sudo chown -R $(whoami):$(whoami) www/

MySQL Connection Refused

Wait for MySQL to fully start:

docker-compose logs mysql

Changes Not Reflecting

  1. Hard refresh browser: Ctrl + F5 (Windows/Linux) or Cmd + Shift + R (Mac)
  2. Clear OPcache: docker exec php-apache php -r "opcache_reset();"
  3. Restart web service: docker-compose restart web

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 Author

Wylou


🏢 Company

PT. Lunexia Tech Horizon


🙏 Acknowledgments

  • PHP Community for amazing tools
  • Docker team for containerization
  • All contributors and users of this project

⭐ Show Your Support

If this project helped you, please give it a ⭐ on GitHub!


About

A modern XAMPP alternative - Complete PHP development environment with Docker. Includes Apache, PHP 8.3, MySQL 8.0, phpMyAdmin, auto-reload, and Laravel support.

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Sponsor this project

Contributors