Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
89
backups/docs-backup-20250731125004/framework/di/README.md
Normal file
89
backups/docs-backup-20250731125004/framework/di/README.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# Dependency Injection Modul
|
||||
|
||||
## Übersicht
|
||||
|
||||
Das DI-Modul implementiert ein Dependency-Injection-Container-System, das die automatische Auflösung und Verwaltung von Abhängigkeiten ermöglicht.
|
||||
|
||||
## Hauptkomponenten
|
||||
|
||||
### Container
|
||||
|
||||
Der zentrale Service-Container, der Instanzen erstellt und verwaltet.
|
||||
|
||||
**Hauptfunktionen:**
|
||||
- Service-Erstellung und -Auflösung
|
||||
- Singleton-Verwaltung
|
||||
- Rekursive Abhängigkeitsauflösung
|
||||
|
||||
### Initializer-Attribut
|
||||
|
||||
Das `#[Initializer]`-Attribut kennzeichnet Klassen, die Services im Container registrieren können.
|
||||
|
||||
**Beispiel:**
|
||||
```php
|
||||
#[Initializer]
|
||||
readonly class AnalyticsInitializer
|
||||
{
|
||||
public function __invoke(Container $container): Analytics
|
||||
{
|
||||
// Service erstellen und konfigurieren
|
||||
return $analytics;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Service definieren
|
||||
|
||||
```php
|
||||
// Service-Interface
|
||||
interface MyServiceInterface
|
||||
{
|
||||
public function doSomething(): void;
|
||||
}
|
||||
|
||||
// Konkrete Implementierung
|
||||
class MyService implements MyServiceInterface
|
||||
{
|
||||
public function doSomething(): void
|
||||
{
|
||||
// Implementierung
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Service registrieren
|
||||
|
||||
```php
|
||||
#[Initializer]
|
||||
class MyServiceInitializer
|
||||
{
|
||||
public function __invoke(Container $container): MyServiceInterface
|
||||
{
|
||||
return new MyService();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Service verwenden
|
||||
|
||||
```php
|
||||
class MyController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly MyServiceInterface $myService
|
||||
) {}
|
||||
|
||||
public function action(): void
|
||||
{
|
||||
$this->myService->doSomething();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Prinzipien
|
||||
|
||||
- **Automatische Auflösung**: Abhängigkeiten werden anhand von Typ-Hints automatisch aufgelöst
|
||||
- **Lazy Loading**: Services werden erst erstellt, wenn sie benötigt werden
|
||||
- **Singleton-Modus**: Standardmäßig werden Services als Singletons verwaltet
|
||||
Reference in New Issue
Block a user