mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-09-27 12:02:00 +02:00
Structure:
- Split development/ (20 files) into development/ (framework reference) and guides/ (how-to)
- Moved 13 how-to files into new guides/ category (auth, cli, error-handling, etc.)
- Moved navbar-rendering.md from system/ into development/
- Deleted empty system/README.md files
- Deleted documentation_gaps.md (all gaps resolved) and redundant info/update.md
Sidebar / navbar:
- Removed all emojis from _sidebar.md (EN + RU) — fixes tree hierarchy rendering
- Removed flag emojis from _navbar.md language switcher
- Removed duplicate entries from the old "System Documentation" section
- Renamed section headers: "Development" -> "Framework Reference" + "Developer Guides"
Content fixes (modules.md EN + RU):
- Updated "Class naming" section: now documents XcVm\Module\{Pascal} namespaces
(was "global PHP namespace — Until PHP namespaces are introduced")
- Updated main module class example to use namespace declaration + use statements
- Updated class naming in ModuleLoader description to FQN
- Replaced installCrontab() manual crontab instruction with getCronEntries() API
- Updated enable/disable section: added ModuleState enum table, updated config examples
- Fixed FAQ answer for disabling a module
Content fixes (bootstrap-contexts.md EN + RU):
- Replaced CONTEXT_* string constants with BootContext enum cases throughout
- Updated boot() signature: string $context -> BootContext $context
- Updated getContext() return type: ?string -> ?BootContext
New framework reference docs (EN + RU):
- docs/{en,ru}/development/event-system.md: EventDispatcher singleton bridge,
#[ListensTo] attribute, getEventSubscribers() array API, stoppable events,
built-in event catalog, custom event authoring, ListensTo attribute reference
- docs/{en,ru}/development/exception-hierarchy.md: full XcVmException tree,
container vs module subtrees, PSR-11 compliance notes, catch-by-subsystem examples
3.5 KiB
3.5 KiB
Bootstrap Contexts
XC_Bootstrap is the single entry point for system initialization.
Each context loads only the subsystems required for its execution path.
The context is expressed as a BootContext enum value.
Quick Reference
| Enum case | Typical usage |
|---|---|
BootContext::MINIMAL |
Scripts that need only paths/config |
BootContext::CLI |
Cron jobs and CLI commands |
BootContext::STREAM |
Streaming endpoints (live, vod, timeshift) |
BootContext::ADMIN |
Admin/reseller panel |
Context Details
BootContext::MINIMAL
Loads constants, paths, config, logger, and error handlers. No database connection.
Includes:
- autoloader (
autoload.php) - path constants (
MAIN_HOME,INCLUDES_PATH, ...) - logger (
Logger::init()) - error helpers (
generateError(),generate404())
Excludes: DB, Redis, sessions, translator, admin APIs.
require_once '/home/xc_vm/bootstrap.php';
XC_Bootstrap::boot(BootContext::MINIMAL);
BootContext::CLI
Used for cron and CLI tasks.
Adds database and legacy core initialization over MINIMAL.
Includes:
- DB connection
LegacyInitializer- optional Redis (
'redis' => true) - optional process title (
'process' => '...')
require_once '/home/xc_vm/bootstrap.php';
XC_Bootstrap::boot(BootContext::CLI, [
'cached' => true,
'process' => 'xc_vm: my-job',
]);
BootContext::STREAM
Lightweight context for high-load streaming endpoints.
Includes:
- DB connection (
cached=true) - flood protection and host verification
Excludes: Redis, translator, admin APIs, sessions.
require_once '/home/xc_vm/bootstrap.php';
XC_Bootstrap::boot(BootContext::STREAM, ['cached' => true]);
BootContext::ADMIN
Full initialization for admin/reseller panel.
Includes:
- secure session (
SameSite=Strict) - DB connection (
cached=false) LegacyInitializer- Redis
- admin/reseller APIs
- translator
- shutdown handler
- status constants and admin globals
require_once '/home/xc_vm/bootstrap.php';
XC_Bootstrap::boot(BootContext::ADMIN);
Subsystem Matrix
| Subsystem | MINIMAL | CLI | STREAM | ADMIN |
|---|---|---|---|---|
| Constants/paths | ✅ | ✅ | ✅ | ✅ |
| Logger | ✅ | ✅ | ✅ | ✅ |
| Flood protection | — | — | ✅ | ✅ |
| Host verification | — | — | ✅ | ✅ |
| Database | — | ✅ | ✅ | ✅ |
| LegacyInitializer | — | ✅ | — | ✅ |
| Redis | — | opt | — | ✅ |
| Session | — | — | — | ✅ |
| Admin API | — | — | — | ✅ |
| Translator | — | — | — | ✅ |
boot() options
XC_Bootstrap::boot(BootContext $context, array $options = []);
| Option | Type | Default | Description |
|---|---|---|---|
cached |
bool |
true for STREAM, false otherwise |
Use cached settings |
redis |
bool |
true for ADMIN, false otherwise |
Connect Redis |
process |
string |
'' |
Process title for CLI |
shutdown |
callable |
built-in | Override shutdown callback |
Idempotency
boot() is executed once per process. Repeated calls are ignored.
XC_Bootstrap::boot(BootContext::ADMIN);
XC_Bootstrap::boot(BootContext::CLI); // ignored
For tests:
XC_Bootstrap::reset();
Public Methods
XC_Bootstrap::getContext(): ?BootContext
XC_Bootstrap::isBooted(): bool
XC_Bootstrap::isCli(): bool
XC_Bootstrap::getDatabase(): ?Database
XC_Bootstrap::getContainer(): ServiceContainer