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
| Key | Value |
| Package name | unvrsl/core-backend |
| Remote URL | git@github.com:olivmiron/core.backend.git |
| Type | Composer 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\DocumentShellFile:
src/htmlTemplateInit/DocumentShell.phpDocumentShell generates clean, standards-compliant HTML document shells.#### Constructor options
| Option | Type | Default | Description |
lang | string | 'en' | <html lang="..."> attribute |
title | string | '' | <title> content |
charset | string | 'utf-8' | <meta charset="..."> |
viewport | string | 'width=device-width, initial-scale=1' | Viewport meta tag |
description | string | '' | <meta name="description"> |
favicon | string | '' | Path to favicon |
bodyClass | string | '' | CSS class on <body> |
htmlClass | string | '' | CSS class on <html> |
head | array | [] | Additional HTML before </head> |
bodyTop | array | [] | Additional HTML after <body> |
bodyBottom | array | [] | Additional HTML before </body> |
#### Methods
| Method | Signature | Description |
open() | open(array $config = []): string | Returns <!doctype html> through opening <body> |
close() | close(array $config = []): string | Returns closing </body></html> plus bodyBottom |
render() | render(string $content = '', array $config = []): string | Full 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.phpHelpers for parsing, formatting, and manipulating datetime strings. See source for available functions.
Updating
composer update unvrsl/core-backend