Skip to content

Commit fbd5c9d

Browse files
schnitzlerclaude
andcommitted
Docker dev environment + PHP 8.1 compatibility fixes
- Add Docker setup (PHP 8.1 + Apache + MySQL 8.0) with Makefile workflow - Add Playwright E2E tests for installation wizard and admin login - Fix trim(null) logic bug in Profiler/Storage/File.php (|| → &&) - Fix array-access-on-bool in papaya_mediadb.php (3 locations) - Fix PAPAYA_PASSWORD_REHASH default to active on fresh install - Fix PHPUnit 9.6 compatibility (return types, bootstrap paths) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0cd9719 commit fbd5c9d

17 files changed

Lines changed: 2428 additions & 175 deletions

File tree

CLAUDE.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# papayaCMS Modernization Project
2+
3+
## Development Environment
4+
5+
- Docker-based: PHP 8.1 + Apache + MySQL 8.0
6+
- Start with: `make up` (then `make composer-install` if first time)
7+
- The CMS runs at http://localhost:8080, admin at http://localhost:8080/papaya/
8+
9+
## Testing Workflow
10+
11+
**Before making code changes**, ensure Docker is running (`make status`). If containers are not running, start them with `make up`.
12+
13+
**After every code change**, run the tests automatically — do not ask the user to run them:
14+
15+
1. `make test` — runs 7,063 PHPUnit unit tests
16+
2. `make db-reset` — reset the database
17+
3. `make e2e` — runs Playwright E2E tests (full installation wizard + admin login)
18+
19+
If tests fail, fix the issue before moving on. If a test failure is pre-existing (not caused by the current change), note it and continue.
20+
21+
**For large or risky changes**, run `make e2e-fresh` instead (full DB reset + E2E).
22+
23+
## Key Commands
24+
25+
| Command | Purpose |
26+
|---|---|
27+
| `make up` | Start containers |
28+
| `make down` | Stop containers |
29+
| `make fresh` | Nuclear reset — rebuild everything from scratch |
30+
| `make test` | PHPUnit unit tests |
31+
| `make e2e` | Playwright E2E (install + admin login) |
32+
| `make e2e-fresh` | Reset DB + rebuild + E2E |
33+
| `make db-reset` | Reset only the database |
34+
| `make shell` | Bash into web container |
35+
| `make status` | Show container status |
36+
37+
## Project Context
38+
39+
- Working branch: `modernize-php`
40+
- Goal: incrementally modernize from PHP 7.2 to current PHP, then functional changes
41+
- Do NOT push to origin unless explicitly asked
42+
- The codebase has ~1,557 PHP files in src/ (1,094 modern + 463 deprecated)
43+
- 811 test files with ~115K lines of test code
44+
45+
## Code Notes
46+
47+
- Database config in `papaya.php` (Docker env reads from environment variables)
48+
- Installer is at `/papaya/install` — uses JS-driven RPC for table creation
49+
- PHPUnit installed via Composer (`vendor/bin/phpunit`), not the old `.phar` in `tools/`

Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM php:8.1-apache
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
libxml2-dev \
6+
libxslt1-dev \
7+
libpng-dev \
8+
libjpeg-dev \
9+
libfreetype6-dev \
10+
libzip-dev \
11+
unzip \
12+
git \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Configure and install PHP extensions
16+
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
17+
&& docker-php-ext-install -j$(nproc) \
18+
dom \
19+
xsl \
20+
gd \
21+
mysqli \
22+
pdo \
23+
pdo_mysql \
24+
zip \
25+
opcache
26+
27+
# Enable Apache modules
28+
RUN a2enmod rewrite
29+
30+
# Set document root to htdocs
31+
ENV APACHE_DOCUMENT_ROOT=/var/www/html/htdocs
32+
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
33+
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
34+
35+
# Allow .htaccess overrides
36+
RUN sed -ri -e 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf
37+
38+
# Install Composer
39+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
40+
41+
# Create papaya-data directory with .htaccess security
42+
RUN mkdir -p /var/www/html/htdocs/papaya-data/media/files \
43+
&& echo -e "Order deny,allow\nDeny from all" > /var/www/html/htdocs/papaya-data/.htaccess \
44+
&& chown -R www-data:www-data /var/www/html/htdocs/papaya-data
45+
46+
WORKDIR /var/www/html

Makefile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
.PHONY: up down fresh test logs shell composer-install status e2e e2e-fresh e2e-debug db-reset db-post-install
2+
3+
# Start the environment
4+
up:
5+
docker compose up -d
6+
@echo ""
7+
@echo "papayaCMS is running at http://localhost:8080"
8+
@echo "MySQL is available at localhost:3306 (user: papaya / pass: papaya)"
9+
10+
# Stop the environment
11+
down:
12+
docker compose down
13+
14+
# Nuclear reset: destroy everything and start fresh
15+
fresh:
16+
docker compose down -v
17+
docker compose build --no-cache
18+
docker compose up -d
19+
docker compose exec web composer install --prefer-dist
20+
@echo ""
21+
@echo "Fresh environment ready at http://localhost:8080"
22+
23+
# Run PHPUnit tests inside the container
24+
test:
25+
docker compose exec web vendor/bin/phpunit
26+
27+
# Run PHPUnit with coverage
28+
test-coverage:
29+
docker compose exec web vendor/bin/phpunit --coverage-html=coverage
30+
31+
# Install composer dependencies
32+
composer-install:
33+
docker compose exec web composer install --prefer-dist
34+
35+
# View logs
36+
logs:
37+
docker compose logs -f
38+
39+
# Open a shell in the web container
40+
shell:
41+
docker compose exec web bash
42+
43+
# Reset only the database (keeps containers running)
44+
db-reset:
45+
docker compose exec db mysql -u root -proot -e "DROP DATABASE IF EXISTS papaya; CREATE DATABASE papaya; GRANT ALL PRIVILEGES ON papaya.* TO 'papaya'@'%';"
46+
@echo "Database reset complete"
47+
48+
# Show container status
49+
status:
50+
docker compose ps
51+
52+
# Apply post-installation settings (password rehash, etc.)
53+
db-post-install:
54+
docker compose exec db mysql -u root -proot papaya < docker/mysql-init/01-post-install.sql
55+
@echo "Post-install settings applied"
56+
57+
# Run E2E tests (Playwright) against running containers, then apply post-install settings
58+
e2e:
59+
@mkdir -p e2e/test-results
60+
cd e2e && npx playwright test
61+
$(MAKE) db-post-install
62+
63+
# Full reset + E2E: destroy DB, rebuild, install, run E2E tests
64+
e2e-fresh:
65+
docker compose down -v
66+
docker compose up -d
67+
docker compose exec web composer install --prefer-dist --quiet
68+
@mkdir -p e2e/test-results
69+
cd e2e && npx playwright test
70+
$(MAKE) db-post-install
71+
72+
# Run E2E tests with browser visible (for debugging)
73+
e2e-debug:
74+
@mkdir -p e2e/test-results
75+
cd e2e && npx playwright test --headed --timeout=120000

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
"papaya/module-default": "dev-master",
3131
"papaya/module-standard": "dev-master",
3232
"papaya/module-domains": "dev-master",
33-
"papaya/module-default-cronjobs": "dev-master"
33+
"papaya/module-default-cronjobs": "dev-master",
34+
"phpunit/phpunit": "^9.6"
35+
},
36+
"config": {
37+
"allow-plugins": {
38+
"papaya/composer-plugins": true
39+
}
3440
}
3541
}

0 commit comments

Comments
 (0)