- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
5.7 KiB
Project Guidelines
This document provides essential information for developers working on the michaelschiemer.de website project.
Build and Configuration Instructions
Environment Setup
The project uses Docker for local development. Make sure you have Docker and Docker Compose installed on your system.
Building the Project
- Clone the repository
- Create a
.envfile based on.env.example(if available) - Build the Docker containers:
./build.sh
The build script includes several resilience mechanisms:
- Checks network connectivity before attempting to pull images
- Flushes DNS cache to avoid DNS resolution issues
- Restarts the Docker daemon if it's not responding
- Multiple build strategies with fallbacks if the primary strategy fails
Starting the Development Environment
Start the Docker containers:
docker-compose up -d
This will start the following services:
- web: Nginx web server (ports 8000, 8080, 443)
- php: PHP application container
- db: MariaDB database (port 33060)
- redis: Redis cache server
- queue-worker: Worker container for processing queued jobs
Required PHP Extensions
The project requires the following PHP extensions:
- dom
- libxml
- curl
- pcntl
- fileinfo
- zlib
- gd
- pdo
- apcu
- redis
- zend-opcache
- openssl
Testing Information
Testing Framework
The project uses Pest PHP for testing, which is a testing framework built on top of PHPUnit with a more expressive syntax.
Running Tests
Run all tests:
./vendor/bin/pest
Run a specific test file:
./vendor/bin/pest tests/path/to/TestFile.php
Run tests with coverage report (requires Xdebug):
XDEBUG_MODE=coverage ./vendor/bin/pest --coverage
Writing Tests
Tests are located in the tests directory, with a structure that mirrors the application code. For example, tests for src/Framework/Random are in tests/Framework/Random.
Test files should:
- Be named with the suffix
Test.php - Use the appropriate namespace (e.g.,
Tests\Framework\Randomforsrc/Framework/Random) - Follow the Pest PHP testing style
Example Test
Here's an example test for the TestableRandomGenerator class:
<?php
declare(strict_types=1);
namespace Tests\Framework\Random;
use App\Framework\Random\TestableRandomGenerator;
test('erzeugt deterministische Bytes mit vorgegebener Länge', function () {
$generator = new TestableRandomGenerator('test-seed');
// Erste Ausführung
$bytes1 = $generator->bytes(10);
expect(strlen($bytes1))->toBe(10);
// Generator zurücksetzen
$generator->reset();
// Zweite Ausführung nach Reset sollte identische Bytes erzeugen
$bytes2 = $generator->bytes(10);
expect($bytes2)->toBe($bytes1);
});
Note that test names are written in German, with descriptive names that explain what the test is checking.
Deployment
The project includes a deployment script (deploy.sh) that deploys the application to a remote server. The deployment process:
- Creates a temporary directory
- Copies project files to the temporary directory (excluding .git, node_modules, vendor, .env)
- Creates an archive of the project
- Creates directories on the remote server
- Transfers the archive to the remote server
- Extracts the archive on the remote server
- Creates an .env file if it doesn't exist
- Sets permissions for storage and cache directories
- Installs dependencies and builds assets
- Restarts Docker containers
- Cleans up temporary files
To deploy the project:
./deploy.sh
Code Style and Quality
Code Style
The project uses PHP CS Fixer for code style checking and fixing. The configuration is defined in .php-cs-fixer.dist.php (or similar).
Run code style check:
composer cs
Fix code style issues:
composer cs-fix
Static Analysis
The project uses PHPStan for static analysis. The configuration is defined in phpstan.neon.
Run static analysis:
composer phpstan
Generate a baseline for static analysis:
composer phpstan-baseline
Project Structure
The project follows a domain-driven design approach with the following main directories:
src/Application: Contains application-specific codesrc/Domain: Contains domain models and business logicsrc/Framework: Contains framework-level codesrc/Infrastructure: Contains infrastructure-level code
The Framework directory contains various components, including:
Analytics: Analytics functionalityCache: Caching functionalityConsole: Console commandsDatabase: Database functionalityHttp: HTTP functionalityRandom: Random number generationSecurity: Security functionalityValidation: Validation functionalityView: View renderingWaf: Web Application Firewall functionality
Additional Development Information
Composer Scripts
The project defines several Composer scripts for common tasks:
composer cs: Run PHP CS Fixer in dry-run modecomposer cs-fix: Run PHP CS Fixer to fix issuescomposer reload: Dump the autoloader optimizedcomposer phpstan: Run PHPStan analysiscomposer phpstan-baseline: Generate a PHPStan baseline
Docker Networks
The Docker services are organized into three networks:
frontend: For services that need to be accessible from outsidebackend: For services that need to communicate with each othercache: For services that need to access the cache
Docker Volumes
The Docker setup includes several volumes for persistent data:
redis_data: Redis datacomposer-cache: Composer cachestorage-data: Storage datavar-data: Var datadb_data: Database dataproject-data: Project dataworker-logs: Worker logsworker-queue: Worker queue