Scriptlog Docs

Scriptlog Documentation

Code reference for the Scriptlog codebase

User Tools

Site Tools


scriptlog:lib:core:bootstrap

This is an old revision of the document!


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&#124;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

^ Alias ^ Fully-qualified name ^
| ''DownloadController'' | [[scriptlog:lib:controller:downloadcontroller&#124;''Scriptlog\Controller\DownloadController'']] |
| ''ConfigurationDao'' | [[scriptlog:lib:dao:configurationdao&#124;''Scriptlog\Dao\ConfigurationDao'']] |
| ''MediaDao'' | [[scriptlog:lib:dao:mediadao&#124;''Scriptlog\Dao\MediaDao'']] |
| ''PageDao'' | [[scriptlog:lib:dao:pagedao&#124;''Scriptlog\Dao\PageDao'']] |
| ''PostDao'' | [[scriptlog:lib:dao:postdao&#124;''Scriptlog\Dao\PostDao'']] |
| ''TopicDao'' | [[scriptlog:lib:dao:topicdao&#124;''Scriptlog\Dao\TopicDao'']] |
| ''UserDao'' | [[scriptlog:lib:dao:userdao&#124;''Scriptlog\Dao\UserDao'']] |
| ''UserTokenDao'' | [[scriptlog:lib:dao:usertokendao&#124;''Scriptlog\Dao\UserTokenDao'']] |
| ''DeleteCommentCmd'' | [[scriptlog:lib:handler:deletecommentcmd&#124;''Scriptlog\Handler\Admin\Comment\DeleteCommentCmd'']] |
| ''EditCommentCmd'' | [[scriptlog:lib:handler:editcommentcmd&#124;''Scriptlog\Handler\Admin\Comment\EditCommentCmd'']] |
| ''ListCommentsCmd'' | [[scriptlog:lib:handler:listcommentscmd&#124;''Scriptlog\Handler\Admin\Comment\ListCommentsCmd'']] |
| ''DeleteTopicCmd'' | [[scriptlog:lib:handler:deletetopiccmd&#124;''Scriptlog\Handler\Admin\Topic\DeleteTopicCmd'']] |
| ''EditTopicCmd'' | [[scriptlog:lib:handler:edittopiccmd&#124;''Scriptlog\Handler\Admin\Topic\EditTopicCmd'']] |
| ''ListTopicsCmd'' | [[scriptlog:lib:handler:listtopicscmd&#124;''Scriptlog\Handler\Admin\Topic\ListTopicsCmd'']] |
| ''NewTopicCmd'' | [[scriptlog:lib:handler:newtopiccmd&#124;''Scriptlog\Handler\Admin\Topic\NewTopicCmd'']] |
| ''DeletePostCmd'' | [[scriptlog:lib:handler:deletepostcmd&#124;''Scriptlog\Handler\Admin\Post\DeletePostCmd'']] |
| ''EditPostCmd'' | [[scriptlog:lib:handler:editpostcmd&#124;''Scriptlog\Handler\Admin\Post\EditPostCmd'']] |
| ''ListPostsCmd'' | [[scriptlog:lib:handler:listpostscmd&#124;''Scriptlog\Handler\Admin\Post\ListPostsCmd'']] |
| ''NewPostCmd'' | [[scriptlog:lib:handler:newpostcmd&#124;''Scriptlog\Handler\Admin\Post\NewPostCmd'']] |
| ''DeletePageCmd'' | [[scriptlog:lib:handler:deletepagecmd&#124;''Scriptlog\Handler\Admin\Page\DeletePageCmd'']] |
| ''EditPageCmd'' | [[scriptlog:lib:handler:editpagecmd&#124;''Scriptlog\Handler\Admin\Page\EditPageCmd'']] |
| ''ListPagesCmd'' | [[scriptlog:lib:handler:listpagescmd&#124;''Scriptlog\Handler\Admin\Page\ListPagesCmd'']] |
| ''NewPageCmd'' | [[scriptlog:lib:handler:newpagecmd&#124;''Scriptlog\Handler\Admin\Page\NewPageCmd'']] |
| ''DeleteUserCmd'' | [[scriptlog:lib:handler:deleteusercmd&#124;''Scriptlog\Handler\Admin\User\DeleteUserCmd'']] |
| ''EditUserCmd'' | [[scriptlog:lib:handler:editusercmd&#124;''Scriptlog\Handler\Admin\User\EditUserCmd'']] |
| ''ListUsersCmd'' | [[scriptlog:lib:handler:listuserscmd&#124;''Scriptlog\Handler\Admin\User\ListUsersCmd'']] |
| ''NewUserCmd'' | [[scriptlog:lib:handler:newusercmd&#124;''Scriptlog\Handler\Admin\User\NewUserCmd'']] |
| ''DeleteMediaCmd'' | [[scriptlog:lib:handler:deletemediacmd&#124;''Scriptlog\Handler\Admin\Media\DeleteMediaCmd'']] |
| ''EditMediaCmd'' | [[scriptlog:lib:handler:editmediacmd&#124;''Scriptlog\Handler\Admin\Media\EditMediaCmd'']] |
| ''ListMediaCmd'' | [[scriptlog:lib:handler:listmediacmd&#124;''Scriptlog\Handler\Admin\Media\ListMediaCmd'']] |
| ''NewMediaCmd'' | [[scriptlog:lib:handler:newmediacmd&#124;''Scriptlog\Handler\Admin\Media\NewMediaCmd'']] |
| ''ActivatePluginCmd'' | [[scriptlog:lib:handler:activateplugincmd&#124;''Scriptlog\Handler\Admin\Plugin\ActivatePluginCmd'']] |
| ''DeactivatePluginCmd'' | [[scriptlog:lib:handler:deactivateplugincmd&#124;''Scriptlog\Handler\Admin\Plugin\DeactivatePluginCmd'']] |
| ''DeletePluginCmd'' | [[scriptlog:lib:handler:deleteplugincmd&#124;''Scriptlog\Handler\Admin\Plugin\DeletePluginCmd'']] |
| ''InstallPluginCmd'' | [[scriptlog:lib:handler:installplugincmd&#124;''Scriptlog\Handler\Admin\Plugin\InstallPluginCmd'']] |
| ''ListPluginsCmd'' | [[scriptlog:lib:handler:listpluginscmd&#124;''Scriptlog\Handler\Admin\Plugin\ListPluginsCmd'']] |
| ''ActivateThemeCmd'' | [[scriptlog:lib:handler:activatethemecmd&#124;''Scriptlog\Handler\Admin\Theme\ActivateThemeCmd'']] |
| ''DeactivateThemeCmd'' | [[scriptlog:lib:handler:deactivatethemecmd&#124;''Scriptlog\Handler\Admin\Theme\DeactivateThemeCmd'']] |
| ''DeleteThemeCmd'' | [[scriptlog:lib:handler:deletethemecmd&#124;''Scriptlog\Handler\Admin\Theme\DeleteThemeCmd'']] |
| ''EditThemeCmd'' | [[scriptlog:lib:handler:editthemecmd&#124;''Scriptlog\Handler\Admin\Theme\EditThemeCmd'']] |
| ''InstallThemeCmd'' | [[scriptlog:lib:handler:installthemecmd&#124;''Scriptlog\Handler\Admin\Theme\InstallThemeCmd'']] |
| ''ListThemesCmd'' | [[scriptlog:lib:handler:listthemescmd&#124;''Scriptlog\Handler\Admin\Theme\ListThemesCmd'']] |
| ''NewThemeCmd'' | [[scriptlog:lib:handler:newthemecmd&#124;''Scriptlog\Handler\Admin\Theme\NewThemeCmd'']] |
| ''AdminActionRegistry'' | [[scriptlog:lib:handler:adminactionregistry&#124;''Scriptlog\Handler\AdminActionRegistry'']] |
| ''ArchiveHandler'' | [[scriptlog:lib:handler:archivehandler&#124;''Scriptlog\Handler\ArchiveHandler'']] |
| ''BlogHandler'' | [[scriptlog:lib:handler:bloghandler&#124;''Scriptlog\Handler\BlogHandler'']] |
| ''CategoryHandler'' | [[scriptlog:lib:handler:categoryhandler&#124;''Scriptlog\Handler\CategoryHandler'']] |
| ''DownloadHandler'' | [[scriptlog:lib:handler:downloadhandler&#124;''Scriptlog\Handler\DownloadHandler'']] |
| ''HandlerRegistry'' | [[scriptlog:lib:handler:handlerregistry&#124;''Scriptlog\Handler\HandlerRegistry'']] |
| ''PageHandler'' | [[scriptlog:lib:handler:pagehandler&#124;''Scriptlog\Handler\PageHandler'']] |
| ''PostHandler'' | [[scriptlog:lib:handler:posthandler&#124;''Scriptlog\Handler\PostHandler'']] |
| ''PrivacyHandler'' | [[scriptlog:lib:handler:privacyhandler&#124;''Scriptlog\Handler\PrivacyHandler'']] |
| ''TagHandler'' | [[scriptlog:lib:handler:taghandler&#124;''Scriptlog\Handler\TagHandler'']] |
| ''DownloadModel'' | [[scriptlog:lib:model:downloadmodel&#124;''Scriptlog\Model\DownloadModel'']] |
| ''ConfigurationService'' | [[scriptlog:lib:service:configurationservice&#124;''Scriptlog\Service\ConfigurationService'']] |
| ''DownloadService'' | [[scriptlog:lib:service:downloadservice&#124;''Scriptlog\Service\DownloadService'']] |
| ''FrontService'' | [[scriptlog:lib:service:frontservice&#124;''Scriptlog\Service\FrontService'']] |

This page is generated from source by 'tools/gendoc'. Edits will be overwritten.

scriptlog/lib/core/bootstrap.1790413761.txt.gz · Last modified: by admin