How 2pisoftware/cmfive-core works
Main Components
• Front Controller / Entry Point: At the root you see files like index.php and web.php. These represent the entry points that receive HTTP requests from the web server.
• Core Engine (Cmfive System): The “system” folder contains the core classes (in system/classes) handling configuration, routing (Request, MenuLinkType, SessionManager) and database interactions (DbPDO, DbMigration, DbObject, DbService). This layer implements the framework’s base functionality.
• Modules: The “system/modules” directory shows many separate modules (admin, auth, channels, file, form, help, insights, main, report, search, tag, task, timelog, tokens, etc.). Each module follows the structure defined in the README – it has required subdirectories (actions, models, templates, install/migrations, and a config.php). These modules encapsulate discrete features and plug into the core engine.
• Database: The framework uses its own ORM (the “DbObject” classes and “DbService” classes) for accessing MySQL. The install/migrations for each module (and in system/install) show that schema evolution is a big part of the system.
• Assets, Libraries and Templates: There’s a clear separation of static assets (CSS, JS, images in assets folders and in system/templates/…) and third-party libraries (FluentPDO, phpThumb, Vue components etc.), which support both frontend and backend functionality.
Relationships and Layers
– Actions (the PHP functions with naming conventions like listsongs_GET, etc.)
– Models (DbObject and DbService classes handling business logic and database interactions)
– Templates (presentation layer files, e.g., listsongs.tpl.php)
– Config (the module’s config.php, which is required to register that module)
• Frontend/Assets: A separate layer for static assets and template files that run on the browser. Mention that the system’s templating engine uses PHP templates as well as integrating with Vue components (present in system/templates/base and Vue-components).
Architectural Patterns and Design Principles
• Modularity: Emphasize that most application functionality is encapsulated in self-contained modules. Each module clearly follows an MVC–like pattern (Actions as controllers, Models for business logic/ORM, and Templates for the view).
• Routing and Naming Conventions: Make a note (perhaps a side annotation) that URL routes match module names and actions (e.g., /music/listsongs) and that actions use naming conventions like <action name>_<HTTP VERB>.