Framework Structure
Overview
The Forge Framework is built with modularity and flexibility in mind. Its architecture consists of several key components that work together to provide a robust foundation for your applications.
Bootstrap Process
The framework's bootstrap process is handled by two main classes:
SimpleBootstrap
The SimpleBootstrap class serves as the entry point for the application, handling the initial setup:
- Defines core paths and directories
- Initializes the application bootstrap
- Sets up session configuration
- Creates and handles the request/response cycle
Bootstrap
The Bootstrap class is responsible for:
- Initializing the dependency injection container
- Setting up the environment
- Registering core services
- Managing modules and applications
- Configuring the middleware pipeline
Module System
The module system is a core feature of Forge, allowing for modular and extensible applications.
ModuleLoader
The ModuleLoader is responsible for:
- Discovering and loading modules from the modules directory
- Validating module compatibility
- Managing module dependencies
- Triggering module lifecycle events
ModuleManifest
Each module includes a manifest (forge.json) that defines:
- Module name and version
- Framework compatibility requirements
- Module dependencies
- Service providers and interfaces
- Configuration defaults
Application Lifecycle
The AppManager class manages the application lifecycle and coordinates between different components:
Lifecycle Events
- beforeBoot/afterBoot
- beforeAppRegister/afterAppRegister
- beforeAppBoot/afterAppBoot
- beforeRequest/afterRequest
- beforeModuleLoad/afterModuleLoad
- beforeModuleRegister/afterModuleRegister
Application Management
The AppManager provides:
- Application registration and boot process
- Event handling and lifecycle hooks
- Service container integration
- Module coordination