Core Architecture Layers
The architecture consists of three main layers:Application Layer
The
Application class extends MicroKernel and serves as the entry pointPackage Layer
Modular packages like
billing encapsulate related functionalityComponent Layer
Fine-grained components within packages handle specific tasks
MicroKernel Foundation
LibreDTE Core extends the Derafu MicroKernel, a lightweight kernel that provides:- Dependency injection container management
- Environment configuration (dev, prod, test)
- Service configuration loading
- Compiler pass registration
Application.php
The MicroKernel approach provides a lightweight alternative to full frameworks, focusing solely on dependency injection and service management without unnecessary overhead.
Singleton Pattern (Optional)
While the library fully supports dependency injection, it also provides a singleton instance for simpler use cases:Service Configuration
All services are configured inconfig/services.yaml with:
- Autowiring
- Interface Binding
- Tagged Services
Services are automatically wired based on type hints:
Compiler Passes
Two custom compiler passes enhance the container:ServiceProcessingCompilerPass
ServiceProcessingCompilerPass
Processes services with the
libredte.lib. prefix, enabling custom service manipulation during container compilation.ServiceConfigurationCompilerPass
ServiceConfigurationCompilerPass
Handles configuration merging and validation for LibreDTE services, ensuring proper setup before runtime.
Environment Management
The application supports multiple environments:- dev: Development with full debugging
- prod: Production-optimized with caching
- test: Testing environment with fixtures
Key Design Principles
Dependency Injection First
All components receive dependencies via constructor injection
Interface-Based Design
Programming to interfaces enables flexibility and testability
Lazy Loading
Services are instantiated only when needed
Strategy Pattern
Document-specific logic uses swappable strategies
Next Steps
Packages & Components
Learn about the package and component structure
Dependency Injection
Deep dive into the DI container usage