How lithephp/framework works
Main Components
• Core Framework Engine (src/App.php)
• HTTP Layer
• Request (src/Http/Request.php)
• Router (src/Http/Router.php & src/Orbis/Http/Router.php)
• Response (src/Http/Response.php)
• Middleware
• Configuration (src/Config: app settings, database config)
• Database Integration
• Database Manager (src/Database/Manager.php)
• ORM/Driver Interfaces (Eloquent, PDO, MySQLi via config)
• Migrations & Seeders (Console/Commands/Migrations, Seeders)
• Console CLI (src/Console & Commands: migrations, controllers, models, middleware, server serve)
• Helpers & Utilities (src/Orbis/helpers.php, exceptions)
• External Dependencies
• Composer Autoloader
• Third-party libraries loaded via composer.json
• Testing Suite (tests/* using PHPUnit)
Relationships & Data Flows
• HTTP Request Flow:
1. Client → Web Server (PHP-FPM/Apache)
2. Composer Autoloader → App Boots (App.php)
3. App loads Config → instantiates Router
4. Router receives Request → matches route → runs Middleware chain → invokes route callback
5. Callback interacts with Database Manager (if needed) → returns Data
6. Response object sent back to Client
• Database Flow:
• App reads database config → Database Manager connects via chosen driver/ORM → executes queries/migrations
• CLI Flow:
1. Developer runs “php line <command>”
2. Autoloader → Console/Line dispatcher → maps to specific Command class (make:migration, migrate, serve, etc.)
3. Command uses Config, Database Manager, File System to scaffold or run tasks
• Testing Flow:
• PHPUnit loads tests → uses Mocked Config/Database → asserts behavior of Request, Router, Database Manager
Architectural Patterns & Principles
• Modularity: clear separation of HTTP, Console, Database, Config
• Middleware chain (inspired by Express.js)
• Convention-over-configuration for Console commands & directory structure
• Single Responsibility in command classes (one command per file)
• Dependency Injection via static configuration in App.php or environment variables
• Extensibility: external ORMs, drivers, custom middleware
Elements
• Clear, human-readable labels for each module
• Rectangles for code modules
• The flow of an HTTP request through Lithe
• How console commands plug into the framework
• How configuration and environment variables drive behavior
• The pluggable database layer and migrations system
• The overall modular structure that makes Lithe simple, flexible, and efficient