Skip to content

A development Docker environment for WordPress with Xdebug integration for debugging.

License

Notifications You must be signed in to change notification settings

jaredchu/wordpress-dev-dockercompose

Repository files navigation

WordPress Dev Containers 🚀

A development Docker environment for WordPress with Xdebug integration for debugging.

Features ✨

  • WordPress with PHP 8.2
  • MySQL 8.0
  • phpMyAdmin
  • Xdebug for debugging
  • SSL support
  • Persistent MySQL data
  • Volume mounting for live code updates
  • Content seeding with fake posts
  • WordPress installation script
  • Environment reset capability
  • Development directory structure

Prerequisites 📋

  • Docker
  • Docker Compose
  • Git

Quick Start 🚀

  1. Clone the repository:
git clone https://github.com/jaredchu/wordpress-dev-dockercompose.git wordpress-dev
cd wordpress-dev
  1. Set up environment:
cp .env.dev .env
cp ./config/xdebug.ini.dev ./config/xdebug.ini
  1. Start the containers:
docker-compose up -d
  1. Install WordPress:
./scripts/install.sh
  1. Access your WordPress site at:
  1. (Optional) Seed the database with fake content:
./scripts/seed.sh

Available Services 🌐

Service URL Default Credentials
WordPress https://localhost Create during setup
phpMyAdmin https://localhost:8080 root / (from .env)

Development Workflow 💻

  1. Code Changes: Edit files in the wordpress directory
  2. Database Access: Use phpMyAdmin at port 8080
  3. Debugging: Configure your IDE to use Xdebug (port 9003)
  4. Content Seeding: Use ./scripts/seed.sh to generate fake posts
  5. Environment Reset: Use ./scripts/reset.sh to start fresh

Development Directory Structure 📁

⚠️ IMPORTANT: Always store your development code in the dev/ directory. Any code stored inside wordpress/ directory will be removed when running reset.sh.

.
├── dev/             # Development directory (SAFE - preserved on reset)
│   ├── plugins/     # Development plugins
│   └── themes/      # Development themes
└── wordpress/       # WordPress installation (WILL BE RESET)

Directory purposes:

  • dev/: Contains development files that are NOT part of the WordPress installation. This is the ONLY safe place for your code.
  • wordpress/: Contains a fresh WordPress installation that can be reset anytime. Do not store development files here.

Environment Variables 🔧

Key variables in .env:

  • MYSQL_ROOT_PASSWORD: Database root password
  • MYSQL_USER: WordPress database user
  • MYSQL_PASSWORD: WordPress database password
  • PHP_XDEBUG_BRANCH: Xdebug version to install

Debugging Setup 🔍

  1. Configure Xdebug in your IDE:

    • Port: 9003
    • Host: localhost
    • Path mappings: /var/www/html./wordpress
  2. Enable debugging in browser:

    • Install Xdebug browser extension
    • Toggle debugging when needed

Troubleshooting 🛠️

  1. Container won't start:

    docker-compose down -v
    docker-compose up -d
  2. Permission issues:

    sudo chown -R $USER:$USER wordpress/
  3. Database connection issues:

    • Check MySQL service is running
    • Verify credentials in .env
    • Ensure ports are not blocked
  4. Reset environment:

    ./scripts/reset.sh

Contributing 🤝

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License 📄

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

About

A development Docker environment for WordPress with Xdebug integration for debugging.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published