Core classes

The classes an app developer meets: the request classes every app extends or uses, the data and config classes, the heartbeat, migrations and upgrade steps, and how helloworld plugs in. Public methods only, the ones you call or override. How to read a class diagram: Diagram guide.

1. Request classes

Framework::dispatch() builds a Request, hands it to the app's Controller, and the controller answers through a Response. Every app also gives the framework an App subclass, booted on every request; a core module extends Module.

Where to look

  • api/core/classes/Controller.class.php, Request.class.php, Response.class.php, App.class.php, AppBootFilter.class.php, Module.class.php.
  • README "Core Backend Classes".

2. Data and config classes

Data access goes through database (MySQL over PDO) or Sqlitedb (the local do.db); System writes the logs; system_config reads api/config.xml and its environment overlay api/config.<env>.xml.

Where to look

  • api/core/classes/db.class.php (database), Sqlitedb.class.php, System.class.php, system_config.class.php, dbSessionToken.class.php.
  • README "Database Layer" and "Configuration".

3. How an app extends the core

An app gives the framework an App subclass and a Controller subclass (the URL's controller name). A DAO creates database handles; it does not extend them. Migrations extend Migration. In helloworld the controller calls HelloTest; the DAO shows the database pattern on its own.

Where to look

  • api/apps/helloworld/: helloworld.class.php, helloworldController.class.php, helloworldDAO.class.php, HelloTest.php, migrations/.
  • Framework::boot_apps() in api/core/Framework.php: where register() and boot() run.
  • The full pattern: The app pattern.

4. Heartbeat

DoSchedulerFunctions::execute_tasks() runs on every heartbeat: it reads the due rows of system_worker, runs system tasks from HeartbeatFunctions and app tasks from each app's DoScheduler subclass, and writes the outcome back.

Where to look

  • api/core/heartbeat/: all six classes; Framework::run_heartbeat() is the entry.
  • README "Heartbeat (Task Scheduler)".

5. Migrations

Migrator finds an app's migration files, runs each Migration in order and records it in system_migrations through MigrationRepository. MigrationCommand is the CLI (api/migrate.php); MigrationScaffold writes new files.

Where to look

  • api/core/Modules/Migrator/; README "Database Migrations".
  • api/apps/helloworld/migrations/: a baseline migration to copy.

6. Upgrade steps

UpgradeGate decides on each request (and each heartbeat) whether pending steps must run; Upgrader runs them.

Upgrader leans on four helpers: the catalog of step files, the planner for the order, the repository for the system_upgrades ledger and the state file in do.db for progress and holds.

Where to look

  • api/core/Modules/Upgrader/; api/upgrades/README.md; docs/upgrading.md.
  • Framework::dispatch() calls UpgradeGate::check(); Framework::run_heartbeat() calls UpgradeGate::heartbeat().