Tereta/Theme Module
Overview
Theme and rendering module. Manages templates (PHTML), styles (SCSS), and scripts (JSX). Each module can register its own templates and assets.
Theme Build
composer theme:install # Install npm dependencies
composer theme:build # Build assets (SCSS → CSS, JSX → JS)
composer theme:watch # Watch mode for development
Built files are output to pub/theme/base/compiled/.
Templates
Templates are .phtml files located in Resources/view/src/ of each module.
Layout system: the controller specifies a master layout (e.g., general) and a page template. The layout wraps the content and includes common elements (header, footer, navigation).
Including components within a template:
<?php $this->render('general/logo') ?>
Styles and Scripts
Each module can define a theme.config.js file with a list of assets to build:
export default {
buildFiles: {
'theme': 'Resources/view/scss/theme.scss',
'dialog': 'Resources/view/jsx/dialog.jsx',
}
};
The build is performed via Vite, which automatically discovers theme.config.js in all modules.
Response Adapters
| Adapter | Purpose |
|---|---|
html | PHTML template rendering (default) |
json | JSON response for API |
redirect | HTTP redirect |
file | File download |
Modular Build
Use theme.config.js to define assets in each module.
Vite automatically scans all project modules by paths:
src///theme.config.js
packages//src//*/theme.config.js
Each theme.config.js exports two lists:
buildFiles— files to compile (SCSS → CSS, JSX → JS)copyFiles— static files to copy topub/theme/base/
// src/Tereta/Thread/theme.config.js
export default {
copyFiles: [
{ from: 'Resources/view/css/thread.css', to: 'css/thread.css' }
],
buildFiles: {}
};
// src/Tereta/Theme/theme.config.js
export default {
copyFiles: [],
buildFiles: {
'theme': 'Resources/view/scss/theme.scss',
'dialog': 'Resources/view/jsx/dialog.jsx',
}
};
During build (composer theme:build), Vite merges buildFiles from all modules into a single set of entry points and compiles them to pub/theme/base/compiled/. Files from copyFiles are copied to pub/theme/base/ after the build.
To add assets from a new module, simply create a theme.config.js in the module directory — Vite will pick it up automatically.
Author and License
Author: Tereta Alexander
Website: tereta.dev
License: Apache License 2.0. See LICENSE.
www.████████╗███████╗██████╗ ███████╗████████╗ █████╗
╚══██╔══╝██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗
██║ █████╗ ██████╔╝█████╗ ██║ ███████║
██║ ██╔══╝ ██╔══██╗██╔══╝ ██║ ██╔══██║
██║ ███████╗██║ ██║███████╗ ██║ ██║ ██║
╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝
.dev
Copyright (c) 2024-2026 Tereta Alexander