DBDiff

Docker Configuration for DBDiff

This Docker setup provides multiple PHP and MySQL version combinations for testing DBDiff across different environments.

Configuration

The Docker setup is configurable via environment variables. Copy .env.example to .env and customize:

cp .env.example .env
# Edit .env to customize ports, database credentials, timeouts, etc.

Environment Variables

Key configuration options:

Available Configurations

PHP Versions

MySQL Versions

Services

CLI Services (for running DBDiff)

Database Services

PHPMyAdmin Services

Usage Examples

Start specific database and PHPMyAdmin

# Start MySQL 8.0 with PHPMyAdmin
docker-compose up -d db-mysql80 phpmyadmin-mysql80

# Start MySQL 8.4 with PHPMyAdmin
docker-compose up -d db-mysql84 phpmyadmin-mysql84

# Start MySQL 9.3 with PHPMyAdmin
docker-compose up -d db-mysql93 phpmyadmin-mysql93

Run DBDiff with specific PHP/MySQL combination

# PHP 7.4 with MySQL 8.0
docker-compose run --rm cli-php74-mysql80 server1.php server2.php database1 database2

# PHP 8.3 with MySQL 8.0
docker-compose run --rm cli-php83-mysql80 server1.php server2.php database1 database2

# PHP 8.4 with MySQL 8.4
docker-compose run --rm cli-php84-mysql84 server1.php server2.php database1 database2

# PHP 8.4 with MySQL 9.3
docker-compose run --rm cli-php84-mysql93 server1.php server2.php database1 database2

Run PHPUnit tests with specific combination

# Run tests with PHP 7.4 and MySQL 8.0
docker-compose run --rm cli-php74-mysql80 phpunit

# Run tests with PHP 8.3 and MySQL 8.0
docker-compose run --rm cli-php83-mysql80 phpunit

# Run tests with PHP 8.4 and MySQL 8.4
docker-compose run --rm cli-php84-mysql84 phpunit

Using the Start Script

The start.sh script provides an easy way to test different PHP/MySQL combinations with automatic cleanup to save disk space.

# Test specific PHP/MySQL combination
./start.sh 8.3 8.0

# Test all combinations (sequentially)
./start.sh all all

# HIGH PERFORMANCE: Test all combinations in parallel
./start.sh all all --parallel

# RECORD MODE: Update expected test fixtures for all versions
./start.sh all all --record

# FAST RESTART: Skip heavy Docker cleanup for faster iterations
./start.sh 8.3 8.0 --fast

# Watch mode - single combination
./start.sh 8.3 8.0 --watch

# Interactive mode - select from menus
./start.sh

Advanced Flags:

Test Runner Modes:

“All” Option Behavior:

Note: The start script automatically cleans up Docker containers, images, volumes, and build cache after each test to save disk space (unless –no-teardown is used).

Stop Script: Use ./stop.sh to manually clean up all containers and resources, especially useful after using --no-teardown:

# Normal cleanup
./stop.sh

# Aggressive cleanup (removes everything)
./stop.sh --aggressive

# Show help
./stop.sh --help

Start all services

# Start all databases and PHPMyAdmin instances
docker-compose up -d

# Or start specific combination
docker-compose up -d db-mysql80 phpmyadmin-mysql80 cli-php83-mysql80

Cleanup

# Stop all services
docker-compose down

# Remove all containers and images
docker-compose down --rmi all --volumes --remove-orphans

Database Connection Details

Default MySQL credentials (configurable via .env):

External Access Ports (configurable via .env)

PHPMyAdmin Access (configurable via .env)

Continuous Integration

The project uses GitHub Actions to ensure full compatibility across all supported versions on every pull request.

Matrix Grid:

Deterministic Testing

DBDiff is now built with deterministic SQL generation. This means:

  1. Tables are processed in alphabetical order.
  2. ALTER statements within a table (columns, keys, constraints) are sorted by item name.
  3. Data operations (INSERT, UPDATE, DELETE) are sorted by primary key.

This ensures that test fixtures are stable across platforms and different database versions.

Support for Modern PHP & PHPUnit