Martin c40d44e4c9 Add redirect tracking and analysis features
Database Schema:
- Added redirect_url VARCHAR(2048) to pages table
- Added redirect_count INT DEFAULT 0 to pages table
- Added index on redirect_count for faster queries

Configuration:
- Created Config class with typed constants (PHP 8.3+)
- MAX_REDIRECT_THRESHOLD = 3 (configurable warning threshold)
- MAX_CRAWL_DEPTH = 50
- CONCURRENCY = 10

Backend Changes:
- Crawler now tracks redirects using Guzzle's redirect tracking
- Extracts redirect history from response headers
- Records redirect count and final destination URL
- Guzzle configured with max 10 redirects and tracking enabled

API Endpoint:
- New endpoint: /api.php?action=redirects
- Analyzes redirect types (permanent 301/308 vs temporary 302/303/307)
- Identifies excessive redirects (> threshold)
- Returns statistics and detailed redirect information

Frontend Changes:
- Added "Redirects" tab with:
  * Statistics overview (Total, Permanent, Temporary, Excessive)
  * Detailed table showing all redirects
  * Visual warnings for excessive redirects (yellow background)
  * Color-coded redirect counts (red when > threshold)
  * Status code badges (green for permanent, blue for temporary)

All quality checks pass:
- PHPStan Level 8: 0 errors
- PHPCS PSR-12: 0 errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 09:40:26 +02:00
2025-10-03 14:02:44 +02:00
2025-10-03 23:19:49 +02:00
2025-10-03 14:13:04 +02:00
2025-10-04 09:29:05 +02:00

Web Crawler

Eine PHP-Anwendung mit MariaDB, die in Docker läuft.

Copyright © 2025 Martin Kiesewetter


Anforderungen

  • Docker
  • Docker Compose

Installation & Start

  1. Container starten:
docker-compose up -d
  1. Container stoppen:
docker-compose down
  1. Container neu bauen:
docker-compose up -d --build

Services

Datenbank Zugangsdaten

  • Host: mariadb
  • Datenbank: app_database
  • Benutzer: app_user
  • Passwort: app_password
  • Root Passwort: root_password

Struktur

.
├── docker-compose.yml      # Docker Compose Konfiguration
├── Dockerfile              # PHP Container Image
├── config/                 # Konfigurationsdateien
│   ├── docker/
│   │   ├── init.sql        # Datenbank Initialisierung
│   │   └── start.sh        # Container Start-Script (unused)
│   └── nginx/
│       └── default.conf    # Nginx Konfiguration
├── src/                    # Anwendungscode
│   ├── api.php
│   ├── index.php
│   ├── classes/
│   └── crawler-worker.php
├── tests/                  # Test Suite
│   ├── Unit/
│   └── Integration/
├── phpstan.neon            # PHPStan Konfiguration
└── phpcs.xml               # PHPCS Konfiguration

Entwicklung

Die Anwendungsdateien befinden sich im src/ Verzeichnis und werden als Volume in den Container gemountet, sodass Änderungen sofort sichtbar sind.

Tests & Code-Qualität

Unit Tests ausführen

Die Anwendung verwendet PHPUnit für Unit- und Integrationstests:

# Alle Tests ausführen
docker-compose exec php sh -c "php /var/www/html/vendor/bin/phpunit /var/www/tests/"

# Alternative mit Composer-Script
docker-compose exec php composer test

Die Tests befinden sich in:

  • tests/Unit/ - Unit Tests
  • tests/Integration/ - Integration Tests

Statische Code-Analyse mit PHPStan

PHPStan ist auf Level 8 (höchstes Level) konfiguriert und analysiert den gesamten Code:

# PHPStan ausführen
docker-compose exec php sh -c "php -d memory_limit=512M /var/www/html/vendor/bin/phpstan analyse -c /var/www/phpstan.neon"

# Alternative mit Composer-Script
docker-compose exec php composer phpstan

PHPStan Konfiguration:

  • Level: 8 (strictest)
  • Analysierte Pfade: src/ und tests/
  • Ausgeschlossen: vendor/ Ordner
  • Konfigurationsdatei: phpstan.neon

Code Style Prüfung mit PHP_CodeSniffer

PHP_CodeSniffer (PHPCS) prüft den Code gegen PSR-12 Standards:

# Code Style prüfen
docker-compose exec php composer phpcs

# Code Style automatisch korrigieren
docker-compose exec php composer phpcbf

PHPCS Konfiguration:

  • Standard: PSR-12
  • Analysierte Pfade: src/ und tests/
  • Ausgeschlossen: vendor/ Ordner
  • Auto-Fix verfügbar mit phpcbf
Description
No description provided
Readme 187 KiB
Languages
Hack 52.4%
PHP 46%
Dockerfile 1.5%
Shell 0.1%