|
| 1 | +# AI Agent Guide - PHPDocker.io |
| 2 | + |
| 3 | +Welcome! This document provides essential context and instructions for AI agents working on the PHPDocker.io project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +PHPDocker.io is a web-based generator for Docker environments tailored for PHP applications. This repository contains both the website and the generator core. |
| 8 | + |
| 9 | +- **Primary Goal**: Provide an easy-to-use interface for generating `docker-compose.yaml` and related Dockerfiles for PHP projects. |
| 10 | +- **Architecture**: Symfony-based web application. |
| 11 | + |
| 12 | +## Tech Stack |
| 13 | + |
| 14 | +- **PHP**: 8.4 |
| 15 | +- **Framework**: Symfony 7.0 |
| 16 | +- **Template Engine**: Twig |
| 17 | +- **Frontend**: Managed via Yarn/NPM, assets served through Symfony Asset component. |
| 18 | +- **Database/Storage**: Redis (for caching/sessions). |
| 19 | +- **Environment**: Docker & Docker Compose. |
| 20 | +- **Orchestration**: Kubernetes (deployment). |
| 21 | + |
| 22 | +## Critical Workflows |
| 23 | + |
| 24 | +### 1. Local Development Setup |
| 25 | +The project uses a `Makefile` to automate environment setup. |
| 26 | +```bash |
| 27 | +make init |
| 28 | +``` |
| 29 | +This command performs: |
| 30 | +- Cache cleanup |
| 31 | +- SSL certificate generation (using `mkcert`) |
| 32 | +- Hosts file entry creation (`phpdocker.local`) |
| 33 | +- Dependency installation (Composer & Yarn) |
| 34 | +- Starting Docker containers |
| 35 | + |
| 36 | +### 2. Common Commands |
| 37 | +Always prefer using `make` commands to ensure consistent environment execution: |
| 38 | +- `make start`: Start the environment. |
| 39 | +- `make stop`: Stop the environment. |
| 40 | +- `make shell`: Open a bash shell inside the PHP container. |
| 41 | +- `make clear-cache`: Clear Symfony cache. |
| 42 | + |
| 43 | +### 3. Testing & Quality |
| 44 | +- **Static Analysis**: `make static-analysis` (runs PHPStan at level 9). |
| 45 | +- **Unit Tests**: `make unit-tests` (runs PHPUnit). |
| 46 | +- **Behavioral Tests**: `make behaviour` (runs Behat). |
| 47 | +- **Coverage**: `make coverage-tests`. |
| 48 | + |
| 49 | +## Coding Standards |
| 50 | + |
| 51 | +- **PHP Standards**: Follow PSR-12 and Symfony best practices. |
| 52 | +- **Strict Typing**: Use strict types in all new PHP files. |
| 53 | +- **Static Analysis**: Ensure all changes pass PHPStan level 9. |
| 54 | +- **Formatting**: Use existing project patterns for indentation and naming. |
| 55 | + |
| 56 | +## Project Structure Highlights |
| 57 | + |
| 58 | +- `src/PHPDocker/Generator`: Core logic for Docker environment generation. |
| 59 | +- `src/Controller`: Symfony controllers for the web interface. |
| 60 | +- `templates/`: Twig templates. |
| 61 | +- `infrastructure/`: Docker and Kubernetes configuration files. |
| 62 | +- `tests/`: |
| 63 | + - `Unit`: Small unit tests. |
| 64 | + - `Functional`: Symfony functional tests. |
| 65 | + - `Behat`: Feature-based behavioral tests. |
| 66 | + |
| 67 | +## Deployment Information |
| 68 | + |
| 69 | +Deployment is container-based: |
| 70 | +- PHP-FPM image: `phpdockerio/site-php` |
| 71 | +- Nginx image: `phpdockerio/site-ngx` |
| 72 | +- Deployment target: Kubernetes (see `infrastructure/kubernetes`). |
| 73 | + |
| 74 | +## Guidance for AI Agents |
| 75 | + |
| 76 | +1. **Environment Awareness**: Always remember that the application runs inside Docker. Use `$(PHP_RUN)` (defined in Makefile as `docker compose run ...`) for executing PHP commands if you are running them from the host. |
| 77 | +2. **Configuration**: Symfony configuration is located in `config/`. Environment variables are managed via `.env` and Symfony Dotenv. |
| 78 | +3. **Tests**: When adding features to the generator, ensure you update or add tests in `tests/Functional/GeneratorTest.php` and relevant Behat features. |
| 79 | +4. **Permissions**: If you encounter file permission issues in `var/`, use `make fix-cache-permissions-dev`. |
0 commit comments