Tereta Framework
Overview
Modular, attribute-driven PHP framework with web and CLI runtimes.
It allows developers to build applications with minimal configuration, leveraging the powerful features of PHP 8.4+ and extending functionality through modules and attributes.
Best suited for commercial projects where extensibility, flexibility and cost-effective development matter.
Key responsibilities:
- Bootstrap web and CLI runtime flows
- Load runtime configuration from
.config.php(can be moved outside the web root via require) - Wire core modules (routing, DB, customer, theme, admin packages)
- Provide extension points via module classes and attributes
Quick Start
1. Installation and setup:
git clone https://gitlab.com/tereta/framework.git .
composer install
cp .config.sample.php .config.php
chmod -R 755 var/
1.1 Locally (without Docker):
php -S localhost:8000 -t pub
1.2 Locally (Docker):
composer docker:up
The composer setup command will automatically perform all necessary steps to set up and run the project, including installing dependencies and building the theme.
composer setup
2. Build theme separately (if needed):
composer theme:install
composer theme:build
3. On Mac with Docker, you can generate local SSL certificates for dev domains:
composer docker:certificate -- domain.dev domain.com
4. Run tests and static analysis:
composer test
Project Structure
.
├── cli.php # CLI entry point <<<
├── docs/ # Documentation
├── pub/
│ ├── index.php # Web application entry point <<<
│ ├── images/
│ ├── media/
│ └── theme/
├── src/
│ ├── config.php # Module configuration
│ └── Tereta/
│ ├── Application/ # Web and CLI application bootstrap
│ ├── Cache/ # Caching: services, adapters, commands
│ ├── Cli/ # CLI: command interfaces, parsing, output
│ ├── Config/ # Configuration
│ ├── Core/ # Shared models, traits, interfaces
│ ├── Customer/ # Auth, registration, account flows
│ ├── Db/ # DB abstraction, models, schemas
│ ├── Di/ # Dependency injection container
│ ├── Email/ # Email: interfaces, transports, factory
│ ├── Files/ # File and directory utilities
│ ├── Help/ # Help pages
│ ├── Library/ # Library components
│ ├── Markdown/ # Markdown processing
│ ├── Page/ # Page controllers
│ ├── Pdo/ # PDO wrappers and exceptions
│ ├── Recaptcha/ # reCAPTCHA config and validation
│ ├── Route/ # Routing, requests, responses
│ ├── Security/ # Security (CSRF, headers)
│ ├── Session/ # Session management
│ ├── Support/ # Support page
│ ├── Theme/ # Rendering, adapters, theme DI
│ └── Thread/ # Threads/discussions
├── packages/
│ └── */ # Packages as separate modules (similar to src/Tereta)
├── dev/
│ ├── docker/ # Docker configuration
│ ├── git/ # Git hooks and scripts
│ └── phpstan/ # PHPStan configuration
├── resources/
├── var/
│ └── cache/ # Cache (must be writable)
├── vendor # Composer dependencies
└── README.md
Environment and Requirements
Required:
- PHP 8.4+
- Extensions:
ctype,dom,iconv,mbstring,pdo,fileinfo,curl - Write access to
var/
- Node.js + npm (theme build)
- Docker Compose (local development environment)
- MySQL or PostgreSQL (for DB)
Configuration file not found— create.config.phpfrom.config.sample.php- DB connection error — check
pdo.dsnand credentials in.config.php - Static files not loading with built-in server — run with
-t pubexactly as shown above
Tests
Run all checks (PHPCS + PHPStan + PHPUnit):
composer test
Individually:
composer phpcs # Code style (PSR-12)
composer phpstan # Static analysis (level 5)
composer phpunit # Unit tests
Tests are located in:
src///Tests
packages///Tests
Deploy and Production
(CI/CD)
CI/CD is configured via GitLab CI (.gitlab-ci.yml). The pipeline includes:
Test stage:
lint— code style check (PHPCS) and static analysis (PHPStan)unit— theme build and PHPUnit execution
devbranch — automatic deploy to development environmentmainbranch — manual deploy to production
SSH_PRIVATE_KEY— private key (file)SSH_HOST,SSH_PORT,SSH_USER— connection parametersSSH_DIRECTORY— project directory on the server
- PHP 8.4+ on the server
composer install --no-devfor production- Theme built (
composer theme:build) var/writable by the web server
Author and License
Author: Tereta Alexander
Website: tereta.dev
License: Apache License 2.0. See LICENSE.
www.████████╗███████╗██████╗ ███████╗████████╗ █████╗
╚══██╔══╝██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗
██║ █████╗ ██████╔╝█████╗ ██║ ███████║
██║ ██╔══╝ ██╔══██╗██╔══╝ ██║ ██╔══██║
██║ ███████╗██║ ██║███████╗ ██║ ██║ ██║
╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝
.dev
Copyright (c) 2024-2026 Tereta Alexander