tereta / page
Requires
- php: >=8.4
- tereta/application: ^1.0
- tereta/cli: ^1.0
- tereta/config: ^1.0
- tereta/core: ^1.0
- tereta/db: ^1.0.0
- tereta/fs: ^1.0
- tereta/route: ^1.0
- tereta/theme: ^1.0
- tereta/utilities: ^1.0.3
README
π Π ΡΡΡΠΊΠΈΠΉ | English
Table of Contents
- Overview
- Configuration
- Static Pages
- Public Media
- Database Pages
- Routing and Render
- CLI Commands
- Author and License
Installation
composer require tereta/page
Overview
Page management module. Supports two approaches: storing pages in the database and file-based static pages. If a page is not found in the database, the module looks for it in the file system. The file system allows easy creation and editing of pages without admin panel access, which is convenient for static sections (e.g., "About", "Contacts", etc.). File-based pages also enable maintaining a Git repository for version control and collaboration.
Configuration
The static pages directory is specified in .config.php:
->set('page', Value::factory()->create()
->set('location', '%s/resources/pages'))
%s is substituted with the project root directory. Pages are organized by site: resources/pages/{site-identifier}/src/.
The module also supports resources/pages/{site-identifier}/pub/ for public assets.
Static Pages
Pages are placed as .html or .phtml files:
resources/pages/site_identifier/src/
βββ index.html # Home page (/)
βββ about.html # /about
βββ about/
βββ team.html # /about/team
Metadata is specified in an HTML comment at the beginning of the file:
<!--
@title: Page Title
@description: Page description
@status: enabled
@css: /path/to/style.css
-->
<h1>Page content</h1>
A page is publicly accessible only with @status: enabled. The @status value is also treated as enabled for 1 or true (case-insensitive).
The @css field can be repeated multiple times β each path will be added as a separate <link rel="stylesheet">.
After adding a new page, run route registration.
Changes to @title and @description in the file do not update existing routes automatically β you need to recreate the route record.
Public Media
Assets can be placed in:
resources/pages/{site-identifier}/pub/
On the first page request the module creates a symlink:
public/media/page/{site-identifier} -> resources/pages/{site-identifier}/pub
Database Pages
The module uses the page table. Key fields:
site_id,route_idβ relations to site and route.identifierβ unique identifier within the site.statusβ whether the page is published.title,description,contentβ page content.
If a database record exists for the current route_id, it takes precedence over a file.
Routing and Render
- Route controller alias:
page. - If a page is not found in DB, the module searches for a file in
resources/pages/{site}/src. - If the page is missing or
statusis disabled, a 404 is returned. - The page wrapper CSS class is derived from the path (
/about/teamβabout_team).
CLI Commands
./cli.php page:registration <site-identifier> # Register static pages in routes (route table)
The command scans the file system, extracts metadata, and creates route records for discovered pages.
Author and License
Author: Tereta Alexander
Website: tereta.dev
License: Apache License 2.0. See LICENSE.
www.ββββββββββββββββββββββββ βββββββββββββββββ ββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββ
βββ ββββββ ββββββββββββββ βββ ββββββββ
βββ ββββββ ββββββββββββββ βββ ββββββββ
βββ βββββββββββ βββββββββββ βββ βββ βββ
βββ βββββββββββ βββββββββββ βββ βββ βββ
.dev
Copyright (c) 2024-2026 Tereta Alexander