⌘K
Docs / Overview / Project / Structure

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.

  1. Controller/: Controllers handle incoming requests, interact with models, and return views using the Laika\Core\App\Template::view() method.
  2. Afterware/: Contains classes that intercept requests after they reach the controller (e.g., LogAfterwareware).
  3. Middleware/: Contains classes that intercept requests before they reach the controller (e.g., DbConnectionMiddleware).
  4. Model/: Contains data structures and database interaction logic.
  5. Providers/: Contains service providers. Relays are registered herer.
  6. 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.

  1. app.php: Application metadata (name, version).
  2. database.php: DB Connection details (Host, credentials, driver).
  3. mail.php: SMTP and Mailer settings.
  4. 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.

  1. web.php: Handles browser-based requests. It maps URLs to controller actions.
  2. 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.

  1. Twig Templates: High-level views (e.g., home.twig or home.html).
  2. functions.php: Contains helper functions available globally within templates.


6. lf-assets/ (Static Assets)

Publicly accessible files used by the frontend.

  1. css/: Stylesheets for the application.
  2. img/: Static images and icons.
  3. js/: Client-side JavaScript files.

7. lf-lang/ (Localisation)

Internationalization files are stored here. Each file follows the {lang_code}.local.php naming convention.

  1. 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.

  1. Access Control: This directory is protected via .htaccess or Nginx rules to prevent external exposure of cached data.
  2. Structure: Files are typically generated with a .php extension.