How chicongst/simple_mvc works
Main Components
• Front Controller – The entry point (index.php) is responsible for handling incoming HTTP requests.
• Bootstrap/Autoload Mechanism – The app/autoload.php in conjunction with the libraries (such as Core.php and Controller.php) is responsible for automatically loading the required classes.
• Routing and Core Logic – The libraries/Core.php likely contains the logic that interprets the request URL and dispatches it to the appropriate controller.
• Controllers – Located in app/controllers (e.g., Auth.php, IndexPage.php, Posts.php, Users.php), these manage the user requests and business logic.
• Models – Found in app/models (e.g., Post.php, User.php), these represent the data objects and interact with the database.
• Views – The views folder holds the front-end presentation files (with subdivisions for includes, posts, and users), along with a rich collection of static assets (CSS, JavaScript, images, and vendor libraries such as Bootstrap, CKEditor, DataTables, and others).
• Configuration – The config directory contains configuration and session initialization files.
• Database & Helper Libraries – The libraries folder includes helpers and core libraries like Database.php (for database interactions), Controller.php (an abstract base for controllers), and the php MVC SQL file for database schema/settings.
Relationships and Data Flow
• Web requests reach the front controller (index.php) which triggers the autoload mechanism.
• The Core component (Core.php) then interprets the URI, selecting and calling the appropriate controller.
• Each controller (in app/controllers) may call one or more models (in app/models) to fetch or update data in the database. The Database library is utilized here.
• After executing business logic, controllers pass data to view templates (in the views folder) for the final output.
• The views use static assets (found in views/include/assets) and vendor libraries for styling, interactivity, and dynamic behavior.
Architectural Patterns and Principles
• MVC Pattern – The project strictly separates concerns: controllers handle input logic, models manage data and business rules, and views handle presentation.
• Separation of Concerns – Configuration, libraries, and autoloading are separated into distinct directories.
• Front Controller Pattern – All requests are funneled through index.php, simplifying route management and initial setup.
Key Technologies and Framework Tools
• PHP (server-side scripting) is used as the backend language.
• SQL (database schema provided in libraries/phpmvc.sql) is involved in data persistence.
• Bootstrap, CKEditor, DataTables, and other third-party assets found under views/include/assets/vendors enhance the front-end.