tereta / theme
Requires
- php: >=8.4
- tereta/config: ^1.0
- tereta/core: ^1.0
- tereta/di: ^1.0
- tereta/route: ^1.0
- tereta/security: ^1.0
Suggests
- tereta/application: Required to register Theme as a module via Application's scanner (uses Module.php). Without it, view services can be wired manually.
README
π Π ΡΡΡΠΊΠΈΠΉ | English
Table of Contents
- Overview
- Theme Build
- Templates
- Styles and Scripts
- Response Adapters
- Modular Build
- Author and License
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