Structure
This page provides a technical overview of the Laika MVC framework's directory structure. It details the purpose of each top-level directory, the data flow between them, and the specific code entities that govern their behavior.
The framework is structured to separate core logic from application-specific code, utilizing a front-controller pattern where all requests are funneled through index.php and routed via the lf-routes/ definitions.
Directory Overview
The following diagram illustrates the relationship between the primary directories and the flow of a request from the entry point to the final output.
1. lf-app/ (Application Layer)
The lf-app/ directory contains the core business logic of the application. It follows the PSR-4 autoloading standard under the App\ namespace.
- Controller/: Controllers handle incoming requests, interact with models, and return views using the Laika\Core\App\Template::view() method.
- Afterware/: Contains classes that intercept requests after they reach the controller (e.g., LogAfterwareware).
- Middleware/: Contains classes that intercept requests before they reach the controller (e.g., DbConnectionMiddleware).
- Model/: Contains data structures and database interaction logic.
- Providers/: Contains service providers. Relays are registered herer.
- Relays/: Contains Relays methods.
2. lf-boot/ (Bootstrap Layer)
This directory handles the initialization of the framework environment.
The primary bootstrapper. It defines the APP_PATH constant and loads global constants from lf-inc/const.php and initializes the Composer autoloader.
3. lf-config/ (Configuration)
Contains PHP files that return associative arrays of configuration settings. These are injected into the application state during the boot process.
- app.php: Application metadata (name, version).
- database.php: DB Connection details (Host, credentials, driver).
- mail.php: SMTP and Mailer settings.
- env.php: Environment-specific toggles (debug, CSRF).
4. lf-routes/ (Routing)
Routing definitions are split by access method. Every route file typically begins with a security check to ensure the APP_PATH constant is defined, preventing direct browser access to the logic files.
- web.php: Handles browser-based requests. It maps URLs to controller actions.
- api.php: Handles stateless API requests, typically returning JSON.
5. lf-templates/ (View Layer)
Laika Framework uses Twig template engine. This directory houses the presentation logic and template files.
- Twig Templates: High-level views (e.g., home.twig or home.html).
- functions.php: Contains helper functions available globally within templates.
6. lf-assets/ (Static Assets)
Publicly accessible files used by the frontend.
- css/: Stylesheets for the application.
- img/: Static images and icons.
- js/: Client-side JavaScript files.
7. lf-lang/ (Localisation)
Internationalization files are stored here. Each file follows the {lang_code}.local.php naming convention.
- en.local.php: Typically defines a LANG class or array holding static translation strings for English.
8. lf-cache/ (Caching)
Internal storage for temporary data, session files, and compiled templates.
- Access Control: This directory is protected via .htaccess or Nginx rules to prevent external exposure of cached data.
- Structure: Files are typically generated with a .php extension.
