Framework
Introduction

Config Files

Beyond the environment, your app is wired up with PHP *.config.php files that register access roles, settings, file paths, languages and migrations. The build collects the registrations and generates typed code from them.

How they load

Any file whose name ends in .config.php is discovered and included from your app at startup — the vendor directory is skipped and the location otherwise does not matter, so a config/ folder is only a convention. The framework ships an example of each file: copy the ones you need into your app and extend them. Register nothing and the framework falls back to its own defaults.

The console commands find them by walking the app, while a request includes the list of them that the ./framework build writes, so it does not walk the app on every call. A new file is only seen by the requests after the next build, and until the first one a request walks the app too. A file that only the console needs, like the ones of the migrations and the icons, ends in .console.php instead, and a request never loads it.

By convention they live together in a config/ folder — one file per concern:

config/
├── Access.config.php            # access roles
├── Settings.config.php          # typed settings
├── File.config.php              # extra storage paths
├── Intl.config.php              # languages & copy dirs
├── Migration.console.php         # migrations folder & last applied
├── MigrationTables.console.php   # table renames
└── MigrationColumns.console.php  # column renames
Config that feeds generated code — access roles and settings especially — takes effect after the next ./framework build.

Access roles

Register the access levels your app uses and group them:

config/Access.config.php
use Framework\Core\AccessRole;

AccessRole::register("General", "General");
AccessRole::register("Admin", "Admin");
AccessRole::register("API", "API");

If you provide no Access.config.php at all, the framework falls back to exactly this configuration — so the General, Admin and API roles always exist. The build turns whichever roles are registered into a typed Access enum — see how it is generated and how routes use it in Authentication.

A role can also name the environment key that holds a token. A request carrying that token is that role, which is how an integration gets in without signing in:

config/Access.config.php
AccessRole::register("Zapier", "API", tokenKey: "ZAPIER_TOKEN");

Settings

Declare typed settings; the build generates a typed getter for each and a migration stores them in the database. See Settings for the types, storage and generated class.

config/Settings.config.php
use Framework\Core\SettingConfig;
use Framework\Core\VariableType;

SettingConfig::register("siteName", "General", VariableType::String);
SettingConfig::register("maxItems", "General", VariableType::Integer);

File paths

Register extra storage paths and sub-directories on top of the built-in ones (source, thumbs, avatars, temp). The build generates a typed Path class for them, and the directories can be created by a migration. See Files & Storage.

config/File.config.php
use Framework\File\FilePath;

FilePath::register("exports");
FilePath::registerDirectory("archive");

Languages

Set the default language and point the internationalization layer at your strings directory, which holds one JSON file per language:

config/Intl.config.php
use Framework\Intl\IntlConfig;

IntlConfig::setDefaultLanguage("en");
IntlConfig::setStringsDir("nls");

The directory holds one JSON file per language, named by its code (en.json, es.json). The framework loads the file that matches the active language and falls back to the default you set above — so a typical nls/ tree looks like this:

nls/
├── en.json          # UI strings, one file per language
└── es.json

An app of your own — a front end, an admin — usually keeps its own strings beside its source, written as a script rather than as JSON. Those directories are added by name, and the only thing the framework does with them is check them:

config/Intl.config.php
IntlConfig::addScriptDir("Desktop Strings", "../desktop/src/NLS/Strings");
IntlConfig::addScriptDir("Desktop Urls", "../desktop/src/NLS/Urls");

Add the directories where the strings are used too, and the same check tells you which keys nothing uses, and which ones the code asks for that no file defines:

config/Intl.config.php
IntlConfig::addSourceDir("src");
IntlConfig::addSourceDir("../desktop/src");

Migrations

The migration config is split across three files. The main one points the runner at your migrations folder and, when adopting it on an existing database, sets the last migration already applied:

config/Migration.console.php
use Framework\Database\Migration\Migration;

Migration::setPath("migrations");
Migration::setLastApplied("2024_01_initial");

A second file lists the table renames, a third the column renames and a fourth the index renames. They run before the schema is synced, so the sync matches your models against the new names instead of dropping and recreating. Table names may be snake_case or PascalCase, ID columns SNAKE_CASE:

config/MigrationTables.console.php
use Framework\Database\Migration\Migration;

Migration::renameTable("old_table", "new_table");
Migration::renameTable("Client", "Customer");
config/MigrationColumns.console.php
use Framework\Database\Migration\Migration;

Migration::renameColumn("TableName", "oldColumn", "newColumn");
Migration::renameColumn("Customer", "CLIENT_ID", "CUSTOMER_ID");
config/MigrationIndexes.console.php
use Framework\Database\Migration\Migration;

Migration::renameIndex("TableName", "oldIndex", "NEW_INDEX");
Migration::renameIndex("Customer", "idx_client_type", "CLIENT_TYPE");