|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +PHPDocker.io is a Symfony 7 web application that generates Docker environments for PHP projects. Users fill out a form and receive a zip archive containing `docker-compose.yaml`, `Dockerfile`, nginx config, PHP ini, and a README. |
| 8 | + |
| 9 | +**Tech stack:** PHP 8.4, Symfony 7.0, Twig, Redis (cache/sessions), Docker Compose (local), Kubernetes (production). |
| 10 | + |
| 11 | +## Commands |
| 12 | + |
| 13 | +All commands run via Docker containers. Use `make` targets rather than running PHP/vendor binaries directly on the host. |
| 14 | + |
| 15 | +```bash |
| 16 | +make init # Full first-time setup (certs, hosts, deps, Docker build, start) |
| 17 | +make start # Start containers |
| 18 | +make stop # Stop containers |
| 19 | +make shell # Bash shell inside PHP container |
| 20 | + |
| 21 | +make static-analysis # PHPStan level 9 on src/ |
| 22 | +make unit-tests # PHPUnit (no coverage) |
| 23 | +make coverage-tests # PHPUnit with xdebug coverage |
| 24 | +make behaviour # Behat behavioral tests |
| 25 | + |
| 26 | +make clear-cache # Clear Symfony var/ cache |
| 27 | +make fix-cache-permissions-dev # Fix var/ permissions if needed |
| 28 | +``` |
| 29 | + |
| 30 | +**Running a single test file:** |
| 31 | +```bash |
| 32 | +docker compose run -e XDEBUG_MODE=coverage --rm php-fpm vendor/bin/phpunit tests/Functional/GeneratorTest.php |
| 33 | +``` |
| 34 | + |
| 35 | +**Running a single Behat scenario:** |
| 36 | +```bash |
| 37 | +docker compose run -e XDEBUG_MODE=coverage --rm php-fpm vendor/bin/behat --colors --name="scenario name" |
| 38 | +``` |
| 39 | + |
| 40 | +The app runs at `https://phpdocker.local:10000` after `make init`. |
| 41 | + |
| 42 | +## Architecture |
| 43 | + |
| 44 | +### Generator Flow |
| 45 | + |
| 46 | +1. User submits the form at `/` (handled by `GeneratorController`) |
| 47 | +2. `ProjectType` (Symfony Form) deserializes request into a `Project` model with nested service option objects (`MySQLOptions`, `PostgresOptions`, etc.) |
| 48 | +3. `Generator` orchestrates file generation, delegating to individual file generators: |
| 49 | + - `Dockerfile.php`, `DockerCompose.php`, `NginxConf.php`, `PhpIni.php`, `Readme.php` |
| 50 | +4. `Archiver` bundles the generated files into a zip and streams it to the browser |
| 51 | + |
| 52 | +### Key Namespaces |
| 53 | + |
| 54 | +- `App\PHPDocker\Generator\` — Core generation engine (file generators + orchestrator) |
| 55 | +- `App\PHPDocker\Project\ServiceOptions\` — Service configuration models (MySQL, Postgres, Redis, etc.) |
| 56 | +- `App\PHPDocker\PhpExtension\` — PHP extension metadata per version (8.2–8.5) |
| 57 | +- `App\Form\Generator\` — Symfony Form types mirroring the domain models |
| 58 | +- `App\Controller\` — Single `GeneratorController` |
| 59 | + |
| 60 | +### Testing Structure |
| 61 | + |
| 62 | +- `tests/Unit/` — Unit tests for isolated classes |
| 63 | +- `tests/Functional/` — Symfony WebTestCase functional tests (`GeneratorTest.php` is the main one) |
| 64 | +- `tests/Behat/` + `features/` — Behavioral tests via Behat/Mink with Symfony driver |
| 65 | + |
| 66 | +When adding generator features, update `tests/Functional/GeneratorTest.php` and `features/generator.feature`. |
| 67 | + |
| 68 | +## Coding Standards |
| 69 | + |
| 70 | +- `declare(strict_types=1)` in every PHP file |
| 71 | +- PHPStan level 9 — all changes must pass with zero errors |
| 72 | +- PSR-12 + Symfony best practices |
| 73 | +- Constructor property promotion with `readonly` where applicable |
| 74 | + |
| 75 | +## Deployment |
| 76 | + |
| 77 | +Container images are built via `make build-and-push` and deployed to Kubernetes via `make deploy`: |
| 78 | +- PHP-FPM image: `phpdockerio/site-php` |
| 79 | +- Nginx image: `phpdockerio/site-ngx` |
| 80 | +- Kubernetes manifests: `infrastructure/kubernetes/` |
0 commit comments