This is an old revision of the document!
Table of Contents
Bootstrap
Layer: Core · Source: lib/core/Bootstrap.php:79 (lines 79–737)
class Bootstrap
Central orchestrator for this blog. This class handles the sequential loading of configurations, utility functions, core services, and global security policies.
Docblock Metadata
| Tag | Value |
|---|---|
@category | Core |
@author | M.Noermoehammad |
@license | MIT |
@version | 1.0.0 |
@since | 1.0.0 |
Inheritance
No parent, interface or trait. This is a root type.
Constants (0)
None.
Properties (3)
| Visibility | Type | Name | Default | Line |
|---|---|---|---|---|
private static | static | $config | []; | 84 |
private static | static | $services | []; | 89 |
private static | static | $allowedExportVars | [ 'db_host', 'db_user', 'db_pwd', 'db_name', 'db_port', 'db… | 91 |
Methods (24)
| Visibility | Method | Summary | Line |
|---|---|---|---|
| public static | initialize() | Initializes the application environment. | 134 |
| private static | loadConfiguration() | Loads the configuration file and extracts required environment variables. | 164 |
| private static | initializeServices() | Orchestrates service instantiation and global registry setup. | 201 |
| private static | createDatabaseConnection() | (undocumented) | 249 |
| private static | defineRoutingRules() | (undocumented) | 277 |
| private static | initializeRegistry() | (undocumented) | 296 |
| private static | createBaseDaos() | (undocumented) | 306 |
| private static | createSession() | (undocumented) | 327 |
| private static | createAuthenticator() | (undocumented) | 355 |
| private static | createThemeRenderer() | (undocumented) | 368 |
| private static | createFrontService() | (undocumented) | 381 |
| private static | createDownloadChain() | (undocumented) | 398 |
| private static | createContentDaos() | (undocumented) | 418 |
| private static | storeInRegistry() | (undocumented) | 433 |
| private static | createDispatcher() | (undocumented) | 447 |
| private static | buildServiceMap() | @SuppressWarnings(PHPMD.ExcessiveParameterList) | 461 |
| private static | buildHandlerRegistry() | (undocumented) | 486 |
| private static | buildAdminActionRegistry() | Build the admin action command registry and register known commands. | 516 |
| private static | initializeI18n() | (undocumented) | 648 |
| private static | applySecurity() | Configures HTTP response headers and global security handlers. | 665 |
| private static | defineCspNonce() | (undocumented) | 677 |
| private static | sendSecurityHeaders() | (undocumented) | 684 |
| private static | sendContentSecurityPolicy() | (undocumented) | 706 |
| private static | initializePostSecurity() | (undocumented) | 717 |
initialize()
public static function initialize(string $appRoot): AppContext
lines 134–156 (23)
Initializes the application environment.
\* Performs the full bootstrap sequence: configuration, utilities, service containerization, and security header enforcement.
| Parameter | Type | Default | Description |
|---|---|---|---|
$appRoot | string | required | The absolute path to the application root directory. |
Returns: ''AppContext'' — AppContext Merged collection of configuration variables and service instances.
loadConfiguration()
private static function loadConfiguration(string $appRoot): array
lines 164–189 (26)
Loads the configuration file and extracts required environment variables.
| Parameter | Type | Default | Description |
|---|---|---|---|
$appRoot | string | required | Path to search for config.php. |
Returns: array — array<string, string> Array containing db_host, app_url, cipher_key, etc.
initializeServices()
private static function initializeServices(array $core_vars): array
lines 201–247 (47)
Orchestrates service instantiation and global registry setup.
\* Note: Registry must be populated before DAOs are instantiated to ensure data access objects have access to the active database connection.
| Parameter | Type | Default | Description |
|---|---|---|---|
$core_vars | array | required | none |
Returns: array — array<string, object|null> Collection of ready-to-use services.
createDatabaseConnection()
private static function createDatabaseConnection(array $core_vars)
lines 249–275 (27)
| Parameter | Type | Default | Description |
|---|---|---|---|
$core_vars | array | required | none |
Returns: (none declared)
defineRoutingRules()
private static function defineRoutingRules(): array
lines 277–294 (18)
Takes no parameters.
Returns: array
initializeRegistry()
private static function initializeRegistry($dbc, array $core_vars, array $rules): void
lines 296–304 (9)
| Parameter | Type | Default | Description |
|---|---|---|---|
$dbc | (untyped) | required | none |
$core_vars | array | required | none |
$rules | array | required | none |
Returns: void
createBaseDaos()
private static function createBaseDaos($dbc): array
lines 306–325 (20)
| Parameter | Type | Default | Description |
|---|---|---|---|
$dbc | (untyped) | required | none |
Returns: array
createSession()
private static function createSession(array $core_vars)
lines 327–353 (27)
| Parameter | Type | Default | Description |
|---|---|---|---|
$core_vars | array | required | none |
Returns: (none declared)
createAuthenticator()
private static function createAuthenticator($dbc, $userDao, $userToken, $validator)
lines 355–366 (12)
| Parameter | Type | Default | Description |
|---|---|---|---|
$dbc | (untyped) | required | none |
$userDao | (untyped) | required | none |
$userToken | (untyped) | required | none |
$validator | (untyped) | required | none |
Returns: (none declared)
createThemeRenderer()
private static function createThemeRenderer($dbc)
lines 368–379 (12)
| Parameter | Type | Default | Description |
|---|---|---|---|
$dbc | (untyped) | required | none |
Returns: (none declared)
createFrontService()
private static function createFrontService()
lines 381–396 (16)
Takes no parameters.
Returns: (none declared)
createDownloadChain()
private static function createDownloadChain($dbc): array
lines 398–416 (19)
| Parameter | Type | Default | Description |
|---|---|---|---|
$dbc | (untyped) | required | none |
Returns: array
createContentDaos()
private static function createContentDaos($dbc): array
lines 418–431 (14)
| Parameter | Type | Default | Description |
|---|---|---|---|
$dbc | (untyped) | required | none |
Returns: array
storeInRegistry()
private static function storeInRegistry($mediaDao, $downloadService, $downloadController, $postDao, $pageDao, $topicDao): void
lines 433–445 (13)
| Parameter | Type | Default | Description |
|---|---|---|---|
$mediaDao | (untyped) | required | none |
$downloadService | (untyped) | required | none |
$downloadController | (untyped) | required | none |
$postDao | (untyped) | required | none |
$pageDao | (untyped) | required | none |
$topicDao | (untyped) | required | none |
Returns: void
createDispatcher()
private static function createDispatcher($dbc, $themeRenderer)
lines 447–458 (12)
| Parameter | Type | Default | Description |
|---|---|---|---|
$dbc | (untyped) | required | none |
$themeRenderer | (untyped) | required | none |
Returns: (none declared)
buildServiceMap()
private static function buildServiceMap($sessionMaker, $sanitizer, $userDao, $userToken, $validator, $configDao, $configService, $authenticator, $dispatcher, $themeRenderer, $mediaDao, $downloadService, $downloadController, $frontService, $postDao, $pageDao, $topicDao): array
lines 461–484 (24)
@SuppressWarnings(PHPMD.ExcessiveParameterList)
| Parameter | Type | Default | Description |
|---|---|---|---|
$sessionMaker | (untyped) | required | none |
$sanitizer | (untyped) | required | none |
$userDao | (untyped) | required | none |
$userToken | (untyped) | required | none |
$validator | (untyped) | required | none |
$configDao | (untyped) | required | none |
$configService | (untyped) | required | none |
$authenticator | (untyped) | required | none |
$dispatcher | (untyped) | required | none |
$themeRenderer | (untyped) | required | none |
$mediaDao | (untyped) | required | none |
$downloadService | (untyped) | required | none |
$downloadController | (untyped) | required | none |
$frontService | (untyped) | required | none |
$postDao | (untyped) | required | none |
$pageDao | (untyped) | required | none |
$topicDao | (untyped) | required | none |
Returns: array
buildHandlerRegistry()
private static function buildHandlerRegistry($themeRenderer): void
lines 486–509 (24)
| Parameter | Type | Default | Description |
|---|---|---|---|
$themeRenderer | (untyped) | required | none |
Returns: void
buildAdminActionRegistry()
private static function buildAdminActionRegistry(): void
lines 516–646 (131)
Build the admin action command registry and register known commands.
Takes no parameters.
Returns: void — void
initializeI18n()
private static function initializeI18n(): void
lines 648–657 (10)
Takes no parameters.
Returns: void
applySecurity()
private static function applySecurity(): void
lines 665–675 (11)
Configures HTTP response headers and global security handlers.
\* Uses utility functions to set CSP, XSS protection, and frame options. Also initializes error handling (Whoops) and HTML purification. \* @return void
Takes no parameters.
Returns: void
defineCspNonce()
private static function defineCspNonce(): void
lines 677–682 (6)
Takes no parameters.
Returns: void
sendSecurityHeaders()
private static function sendSecurityHeaders(): void
lines 684–704 (21)
Takes no parameters.
Returns: void
sendContentSecurityPolicy()
private static function sendContentSecurityPolicy(): void
lines 706–715 (10)
Takes no parameters.
Returns: void
initializePostSecurity()
private static function initializePostSecurity(): void
lines 717–736 (20)
Takes no parameters.
Returns: void
Imports
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
