Skip to content

Common Troubleshooting

Häufige Probleme und Lösungen bei der Entwicklung mit der Appiyon-Plattform.

Composer Issues

Out of Memory

Problem:

bash
PHP Fatal error: Allowed memory size exhausted

Lösung:

bash
php -d memory_limit=-1 /usr/local/bin/composer install

Package Conflicts

Problem:

bash
Your requirements could not be resolved to an installable set of packages.

Lösung:

bash
# Dependencies neu berechnen
composer update --with-all-dependencies

# Oder nur spezifisches Package
composer update symfony/framework-bundle --with-dependencies

Autoloader Issues

Problem:

bash
Class 'App\...' not found

Lösung:

bash
composer dump-autoload

# Oder mit Optimization
composer dump-autoload -o

Cache Problems

Stale Cache

Problem:

  • Änderungen werden nicht übernommen
  • Alte Config-Werte werden verwendet
  • Services nicht gefunden

Lösung:

bash
php bin/console cache:clear
php bin/console cache:warmup

# Wenn das nicht hilft, manuell löschen
rm -rf var/cache/*

Permission Denied

Problem:

bash
Failed to write cache file

Lösung:

bash
# Permissions setzen
chmod -R 777 var/cache/
chown -R www-data:www-data var/cache/

# Oder für Development
chmod -R 777 var/

Database Issues

Connection Refused

Problem:

bash
SQLSTATE[08006] Connection refused

Lösung:

bash
# PostgreSQL läuft nicht
sudo systemctl start postgresql

# Port prüfen
netstat -tlnp | grep 5432

# Verbindung testen
psql -U appiyonadmin -d symfony -h localhost

# DATABASE_URL prüfen
php bin/console debug:container --env-var=DATABASE_URL

Password Special Characters

Problem:

bash
SQLSTATE[08P01] Invalid password

Lösung:

bash
# Sonderzeichen URL-encoden
# @ → %40
# # → %23
# $ → %24
# % → %25
# & → %26

# Beispiel:
# Password: "p@ss$word"
# Encoded: "p%40ss%24word"
DATABASE_URL="postgresql://user:p%40ss%24word@host/db"

Schema Out of Sync

Problem:

bash
The database schema is not in sync with the current mapping file

Lösung:

bash
# Schema validieren
php bin/console doctrine:schema:validate

# Diff anzeigen
php bin/console doctrine:schema:update --dump-sql

# Neue Migration erstellen
php bin/console doctrine:migrations:diff

# Migration ausführen
php bin/console doctrine:migrations:migrate

Service Container Issues

Service Not Found

Problem:

bash
Service "App\..." not found

Lösung:

bash
# Services-Liste prüfen
php bin/console debug:container

# Spezifischen Service suchen
php bin/console debug:container Admin

# services.yaml prüfen
# - Namespace korrekt?
# - Resource-Pfad korrekt?
# - Exclude-Patterns richtig?

# Cache leeren
php bin/console cache:clear

Circular Reference

Problem:

bash
Circular reference detected for service "App\..."

Lösung:

  • Dependency-Graph überprüfen
  • Lazy Loading nutzen:
php
public function __construct(
    private readonly ContainerInterface $container
) {}

private function getMyService(): MyService
{
    return $this->container->get(MyService::class);
}

Cannot Autowire

Problem:

bash
Cannot autowire service "App\...": argument "$..." has no type-hint

Lösung:

php
// Type-Hint hinzufügen
public function __construct(
    MyService $myService  // Richtig
) {}

// Oder in services.yaml binden
services:
    _defaults:
        bind:
            $myService: '@App\MyService'

Routing Issues

Route Not Found

Problem:

bash
404 Not Found
No route found for "GET /admin"

Lösung:

bash
# Routes auflisten
php bin/console debug:router

# Spezifische Route
php bin/console debug:router admin

# Route-Cache leeren
php bin/console cache:clear

# routes.yaml prüfen
# - Controller-Pfad korrekt?
# - Route registered?

Apache: No Rewrite

Problem:

  • Alle Routes → 404
  • Nur /index.php funktioniert

Lösung:

bash
# mod_rewrite aktivieren
sudo a2enmod rewrite
sudo systemctl restart apache2

# .htaccess vorhanden?
ls -la public/.htaccess

# VirtualHost AllowOverride
<Directory /path/to/public>
    AllowOverride All
</Directory>

PHP Extension Issues

Extension Not Found

Problem:

bash
Fatal error: Class 'PDO' not found

Lösung:

bash
# Extensions prüfen
php -m

# Fehlende Extension installieren (Ubuntu)
sudo apt install php8.2-pdo php8.2-pgsql

# PHP-FPM neu starten
sudo systemctl restart php8.2-fpm

# Apache neu starten
sudo systemctl restart apache2

Required Extensions

bash
# Check all required
php -m | grep -E "pdo|pdo_pgsql|intl|mbstring|xml|zip|curl|json|tokenizer|ctype"

# Install missing (Ubuntu)
sudo apt install php8.2-common php8.2-cli php8.2-pdo php8.2-pgsql \
  php8.2-intl php8.2-mbstring php8.2-xml php8.2-zip php8.2-curl

Environment Issues

APP_ENV Not Set

Problem:

  • Wrong environment aktiv
  • Debug-Modus in Production

Lösung:

bash
# .env.local prüfen
cat .env.local | grep APP_ENV

# Oder direkt setzen
export APP_ENV=dev

# Validieren
php bin/console about

APP_SECRET Missing

Problem:

bash
Environment variable "APP_SECRET" is not defined

Lösung:

bash
# Neu generieren
php -r "echo bin2hex(random_bytes(16));"

# In .env.local setzen
APP_SECRET=generated_secret_here

# Cache leeren
php bin/console cache:clear

Permission Issues

Cannot Write to Directory

Problem:

bash
Permission denied: var/log/dev.log

Lösung:

bash
# Permissions setzen
chmod -R 775 var/
chown -R www-data:www-data var/

# Für Development (unsicher für Production!)
chmod -R 777 var/

Wrong User

Problem:

  • CLI funktioniert, Web nicht (oder umgekehrt)

Lösung:

bash
# Cache/Logs für beide Nutzer (CLI & Web) beschreibbar
sudo setfacl -R -m u:www-data:rwX -m u:$(whoami):rwX var/
sudo setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwX var/

Migration Issues

Siehe: Troubleshooting Migrations

Console Command Issues

Command Not Found

Problem:

bash
Command "admin:create" is not defined

Lösung:

bash
# Command registriert?
php bin/console list admin

# services.yaml prüfen
# App\Appi\Dev\Console\Command\:
#     resource: '../src/Appi/Dev/Console/Command'
#     tags: ['console.command']

# Cache leeren
php bin/console cache:clear

Command Fails Silently

Problem:

  • Command läuft, aber keine Ausgabe
  • Exit Code 0, aber nichts passiert

Lösung:

bash
# Verbosity erhöhen
php bin/console admin:create -vvv

# Debug-Modus
APP_DEBUG=1 php bin/console admin:create

# Logs prüfen
tail -f var/log/dev.log

Doctrine Issues

Entity Not Mapped

Problem:

bash
Class "App\Appi\Infrastructure\Admin\Entity\Admin" is not a valid entity or mapped super class

Lösung:

bash
# doctrine.yaml prüfen
# Mapping für Layer vorhanden?

# Cache leeren
php bin/console cache:clear

# Mapping-Info
php bin/console doctrine:mapping:info

Migration Executed Flag Wrong

Problem:

  • Migration wurde manuell ausgeführt, aber Doctrine denkt nicht

Lösung:

sql
-- Als postgres User
psql -U appiyonadmin -d symfony

-- Prüfen
SELECT * FROM doctrine_migration_versions;

-- Manuell als executed markieren
INSERT INTO doctrine_migration_versions (version, executed_at, execution_time)
VALUES ('DoctrineMigrations\\Infrastructure\\Version0001', NOW(), 1);

EasyAdmin Issues

Siehe: Troubleshooting Admin

Testing Issues

Test Database Not Created

Problem:

bash
SQLSTATE[08006] database "symfony_test" does not exist

Lösung:

bash
# Test-DB erstellen
php bin/console doctrine:database:create --env=test

# Migrations ausführen
php bin/console doctrine:migrations:migrate --env=test --no-interaction

Tests Failing Randomly

Problem:

  • Tests fail manchmal, manchmal nicht
  • Abhängig von Ausführungsreihenfolge

Lösung:

  • Shared State zwischen Tests
  • Database Transactions nutzen
  • Test Isolation sicherstellen
php
protected function setUp(): void
{
    $this->connection->beginTransaction();
}

protected function tearDown(): void
{
    $this->connection->rollBack();
}

Performance Issues

Slow Requests

Lösung:

bash
# Web Profiler nutzen
# Im Dev-Modus unten links Toolbar öffnen

# Query-Profiling
# config/packages/dev/doctrine.yaml
doctrine:
    dbal:
        logging: true
        profiling: true

# Slow Queries finden
SELECT query, calls, total_time, mean_time
FROM pg_stat_statements
ORDER BY mean_time DESC
LIMIT 10;

High Memory Usage

Lösung:

bash
# OPcache aktivieren
; php.ini
opcache.enable=1
opcache.memory_consumption=256

# Doctrine Query Cache
# config/packages/prod/doctrine.yaml
doctrine:
    orm:
        query_cache_driver:
            type: pool
            pool: doctrine.system_cache_pool

Debugging Tools

Symfony Debug Toolbar

Im Dev-Modus automatisch aktiv am unteren Bildschirmrand.

Dump & Die

php
// In Controller/Service
dump($variable);
dd($variable); // Dump and Die

Logger

php
$this->logger->debug('Debug message', ['context' => $data]);
$this->logger->info('Info message');
$this->logger->error('Error message');

Profiler

bash
# Im Browser
# Toolbar öffnen → Klick auf Zeitanzeige

# CLI
php bin/console debug:router
php bin/console debug:container
php bin/console debug:event-dispatcher
php bin/console debug:config framework

Logs

bash
# Development Log
tail -f var/log/dev.log

# Production Log
tail -f var/log/prod.log

# Apache Error Log
tail -f /var/log/apache2/error.log

# PostgreSQL Log
tail -f /var/log/postgresql/postgresql-16-main.log

Quick Fixes Checklist

Wenn etwas nicht funktioniert:

  1. Cache leeren

    bash
    php bin/console cache:clear
  2. Logs prüfen

    bash
    tail -f var/log/dev.log
  3. Permissions prüfen

    bash
    ls -la var/
    chmod -R 777 var/  # Dev only!
  4. Database-Verbindung testen

    bash
    psql -U appiyonadmin -d symfony -h localhost
  5. Services prüfen

    bash
    php bin/console debug:container
  6. Routes prüfen

    bash
    php bin/console debug:router
  7. Schema validieren

    bash
    php bin/console doctrine:schema:validate
  8. Environment prüfen

    bash
    php bin/console about
    php bin/console debug:container --env-vars

Getting Help

Wenn nichts hilft:

  1. Logs sammeln

    bash
    cat var/log/dev.log
    cat /var/log/apache2/error.log
  2. Environment-Info

    bash
    php bin/console about
    php -v
    php -m
  3. Config prüfen

    bash
    php bin/console debug:config framework
    php bin/console debug:config doctrine
  4. Reproduktionsschritte dokumentieren

  5. Known Issues prüfen: Known Issues

Weitere Ressourcen

Built with VitePress