How brunoggdev/hefestosphp works
Project Type and Purpose
• This is a lightweight, zero-dependency PHP MVC framework (“HefestosPHP”) plus a sample “app” skeleton.
• Its goal is to teach beginners the core concepts of MVC (Models, Views, Controllers), routing, and database access in Portuguese, without the complexity of full-blown frameworks.
High-Level Components
a. Public/Web Root
• public/index.php (front controller)
• .htaccess (rewrites all requests to index.php)
• hefestos.css (optional static asset)
b. Application Layer (app/)
• Config (routing, database, filters, initialization)
• Controllers (ExemploController.php)
• Models (ExemploModel.php)
• Views (home.php, componentes/)
• Filtros (request filters)
• Database migrations/tables and SQLite file
• Testes (unit tests)
• auxiliares.php (helpers)
c. Framework Core (system/)
• Core (App.php, Controller.php, Model.php, Entidade.php)
• Database layer (Database.php, Tabela.php)
• Routing (Rota, Requisicao, Redirecionar, Filtros)
• CLI tooling (generators/templates for controllers, models, tables, etc.)
• Ferramentas (HTTP client, session, validator, upload, etc.)
• Error handling (exceptions)
• Views (404, 500, debug, maintenance)
• autoloader and iniciar_app.php
d. CLI/“forja” Directory
• (Possibly custom generators or project scaffolding)
Interactions and Data Flow
1. Browser → public/index.php
2. index.php → system/hefestos_autoloader → system/iniciar_app → system/Core/App
3. App uses system/Rotas to match incoming URI to a Controller/Action
4. Controller (in app/Controllers) invokes Models (app/Models → system/Database)
5. Model interacts with the DB (SQLite by default or other via database.php config)
6. Controller passes data to Views (app/Views or system/Views on errors)
7. View templates render HTML → Response sent to Browser
8. Optional filters (app/Filtros + system/Rotas/Filtros) execute before/after controllers
9. CLI (system/CLI and forja/) can be invoked via terminal to generate code or run migrations/tests
Architectural Patterns and Principles
• MVC separation: Controllers handle HTTP logic, Models handle data, Views handle presentation.
• Front Controller pattern: a single entry point (index.php) dispatches requests.
• Layered architecture: clear boundary between the user’s app code (app/) and the framework core (system/).
• Convention over configuration: default folder structure and naming.
• Extensibility via CLI templates and helper files.