Core Docs

core.backend Code Reference

core.backend Code Reference



> Sub-sections: 00-init — file structure, environment, setup · 01-files — per-file code inventory

core.backend is a private Composer library of reusable PHP helpers for the UNVRSL ecosystem. It provides utilities such as an HTML template initializer (DocumentShell) and datetime parsing functions — shared across all application projects rather than duplicated.

Repository



KeyValue





Package nameunvrsl/core-backend
Remote URLgit@github.com:olivmiron/core.backend.git
TypeComposer library (private via VCS)
PHP requirement>= 8.1

Installation



{
"repositories": [
{
"type": "vcs",
"url": "git@github.com:olivmiron/core.backend.git"
}
],
"require": {
"unvrsl/core-backend": "dev-main"
}
}


Autoloading & Bootstrap



"autoload": {
"psr-4": {
"UNVRSL\\Core\\": "src/"
},
"files": [
"bootstrap/init.php"
]
}


The files entry ensures bootstrap/init.php is always loaded on every request.




Services



DocumentShell — HTML Template Initializer



Namespace: UNVRSL\Core\htmlTemplateInit\DocumentShell

File: src/htmlTemplateInit/DocumentShell.php

DocumentShell generates clean, standards-compliant HTML document shells.

#### Constructor options


OptionTypeDefaultDescription












langstring'en'<html lang="..."> attribute
titlestring''<title> content
charsetstring'utf-8'<meta charset="...">
viewportstring'width=device-width, initial-scale=1'Viewport meta tag
descriptionstring''<meta name="description">
faviconstring''Path to favicon
bodyClassstring''CSS class on <body>
htmlClassstring''CSS class on <html>
headarray[]Additional HTML before </head>
bodyToparray[]Additional HTML after <body>
bodyBottomarray[]Additional HTML before </body>

#### Methods


MethodSignatureDescription




open()open(array $config = []): stringReturns <!doctype html> through opening <body>
close()close(array $config = []): stringReturns closing </body></html> plus bodyBottom
render()render(string $content = '', array $config = []): stringFull document

#### Example

<?php
require __DIR__ . '/vendor/autoload.php';

use UNVRSL\Core\htmlTemplateInit\DocumentShell;

$doc = new DocumentShell([
'title' => 'My App',
'description' => 'A demo project powered by core.backend',
'favicon' => '/favicon.ico',
'bodyClass' => 'dark-theme',
'head' => ['<link rel="stylesheet" href="/styles.css">'],
'bodyBottom' => ['<script src="/app.js"></script>'],
]);

echo $doc->open();
echo '<main><h1>Hello World</h1></main>';
echo $doc->close();





Datetime Parsers



File: src/datetime/datetime-parsers.php

Helpers for parsing, formatting, and manipulating datetime strings. See source for available functions.




Updating



composer update unvrsl/core-backend