Files
michaelschiemer/.deployment-backup/ansible/netcup-simple-deploy/SETUP-PHP.md
Michael Schiemer 9b74ade5b0 feat: Fix discovery system critical issues
Resolved multiple critical discovery system issues:

## Discovery System Fixes
- Fixed console commands not being discovered on first run
- Implemented fallback discovery for empty caches
- Added context-aware caching with separate cache keys
- Fixed object serialization preventing __PHP_Incomplete_Class

## Cache System Improvements
- Smart caching that only caches meaningful results
- Separate caches for different execution contexts (console, web, test)
- Proper array serialization/deserialization for cache compatibility
- Cache hit logging for debugging and monitoring

## Object Serialization Fixes
- Fixed DiscoveredAttribute serialization with proper string conversion
- Sanitized additional data to prevent object reference issues
- Added fallback for corrupted cache entries

## Performance & Reliability
- All 69 console commands properly discovered and cached
- 534 total discovery items successfully cached and restored
- No more __PHP_Incomplete_Class cache corruption
- Improved error handling and graceful fallbacks

## Testing & Quality
- Fixed code style issues across discovery components
- Enhanced logging for better debugging capabilities
- Improved cache validation and error recovery

Ready for production deployment with stable discovery system.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 12:04:17 +02:00

3.6 KiB

PHP Projekt Setup für Netcup

Projektstruktur

Das Deployment erwartet diese Struktur in deinem Hauptprojekt:

dein-projekt/                  # Hauptordner
├── ansible/                  # Hier sind wir jetzt
│   └── netcup-simple-deploy/
├── docker/                   # Docker-Konfiguration
│   ├── Dockerfile            # (optional, wird sonst automatisch erstellt)
│   └── docker-compose.yml    # (optional)
├── src/                      # PHP Framework/Library Dateien
│   ├── classes/
│   ├── includes/
│   └── ...
├── public/                   # Web-Root (öffentlich zugänglich)
│   ├── index.php            # Haupteinstiegspunkt
│   ├── css/
│   ├── js/
│   ├── images/
│   └── ...
├── storage/                  # (optional) Logs, Cache, etc.
├── cache/                    # (optional) Cache-Dateien
├── logs/                     # (optional) Log-Dateien
└── .env                      # (optional) Umgebungsvariablen

Quick Setup

1. Konfiguration

cd ansible/netcup-simple-deploy
vim inventory/hosts.yml

Ändere diese Werte:

ansible_host: DEINE-NETCUP-IP
domain: "deine-domain.com"
ssl_email: "deine@email.com"
local_app_path: "../.."        # Zeigt auf dein Hauptprojekt
php_version: "8.2"             # PHP Version

2. Deployment

make deploy

Das war's! Deine PHP-App läuft unter https://deine-domain.com

Was passiert beim Deployment?

  1. Dateien übertragen: public/, src/, docker/ → Server
  2. Dockerfile erstellen: Falls keins in docker/ vorhanden
  3. Docker Container bauen: PHP + Apache + deine App
  4. Nginx Proxy: SSL-Termination und Weiterleitung
  5. SSL-Zertifikat: Automatisch mit Let's Encrypt

Für verschiedene PHP-Setups

Eigenes Dockerfile verwenden

Lege dein Dockerfile in docker/Dockerfile:

FROM php:8.2-apache

# Deine spezifischen PHP Extensions
RUN docker-php-ext-install pdo pdo_mysql

# Custom Apache Config
COPY docker/apache.conf /etc/apache2/sites-available/000-default.conf

# App Dateien
COPY public/ /var/www/html/
COPY src/ /var/www/src/

EXPOSE 80

Mit Composer Dependencies

FROM php:8.2-apache

# Composer installieren
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Dependencies installieren
COPY composer.json composer.lock /var/www/
WORKDIR /var/www
RUN composer install --no-dev --optimize-autoloader

# App kopieren
COPY public/ /var/www/html/
COPY src/ /var/www/src/

Mit Database

Erweitere inventory/hosts.yml:

app_env:
  APP_ENV: "production"
  DATABASE_HOST: "your-db-host"
  DATABASE_NAME: "your-db-name"
  DATABASE_USER: "your-db-user"
  DATABASE_PASS: "your-db-password"

Nützliche Befehle

# Logs anschauen
make logs
make error-logs

# Cache löschen
make clear-cache

# Permissions reparieren
make fix-permissions

# Composer auf Server ausführen
make composer-install

# Live logs verfolgen
make tail-logs

# SSH auf Server
make ssh

Troubleshooting

App lädt nicht?

# Apache Fehler-Logs prüfen
make error-logs

# Allgemeine Logs
make logs

# Container Status
make status

Permissions-Probleme?

# Permissions reparieren
make fix-permissions

Nach Code-Änderungen?

# Einfach neu deployen
make deploy

Database-Verbindung?

# Umgebungsvariablen prüfen
ansible all -m shell -a "docker exec \$(docker ps -q | head -1) env | grep DATABASE"

Das Setup ist optimiert für deine bestehende Projektstruktur - keine Änderungen an deinem Code nötig! 🎉