How vgalvoso/phpeasy works
Project Type and Purpose
• PHPEasy is a lightweight, API-centric PHP “mini-framework” for building REST APIs and full-stack web apps with minimal abstraction.
• It uses file-based routing: files in the View folder map to URL routes; files in the api folder map to REST endpoints.
High-Level Components
• Client Layer
– Web Browser (renders Views + static assets)
– API Consumer (e.g., AJAX, Postman)
• Web Server Layer
– Apache/Nginx + .htaccess rewrite rules
– Front Controller (index.php)
• Framework Core
– Core/Config.php (configuration loader)
– Core/Database.php + Core/DAL.php (DB abstraction)
– Core/Helper.php (routing, session, response helpers)
– Core/Validator.php (input validation)
• Presentation Layer
– View/*.php (server-rendered pages)
– public/css/mystyle.css, public/js/vanscript.js (static assets)
• API Layer
– api/*.php (REST APIs implemented as get(), post(), patch(), delete(), etc.)
• Data Store
– MySQL / MSSQL / SQLite (configured in Core/Database.php)
Component Relationships and Data Flows
1. Client → Web Server: HTTP requests for pages, assets, or API endpoints
2. Web Server → Front Controller (index.php): for view routes
3. Front Controller → Core/Helper (to load appropriate View file) → Response → Client
4. Client AJAX/API Consumer → Web Server → api/*.php → Core/Helper\startAPI()
5. API Handler → Core/DAL → Database → Core/Helper\response() → Client
6. Static asset requests → Web Server → public/css, public/js directly served
Architectural Patterns & Design Principles
• File-Based Routing: routes derive directly from file structure under View/ and api/
• Procedural-Plus-Modular: minimal OOP (DAL class) combined with procedural functions for handlers
• Separation of Concerns:
– Presentation (View/)
– Business/API logic (api/)
– Core utilities (Core/)
– Static resources (public/)
• Lightweight DAL vs. full ORM for performance
• Composer for dependency/autoloading