Database Schema Reference
FW uses a strictly typed compile-time Data Mapper instead of Active Record. The schema is defined centrally in database/schema.yaml.
Running fw build:db compiles this file into:
class [Entity]Model: A strongly typed DTO.Base[Entity]Repository: Pre-compiled raw SQL mapping exactly to the schema, preventing N+1 queries.- SQL Migration Scripts in
database/migrations/.
Writing schema.yaml
yaml
models:
User:
id: uuid @primary
email: string @unique
age: int?
is_active: boolSupported Data Types
FW maps simple YAML data types directly into PHP primitive types and SQL column structures.
string: StandardVARCHAR(255). Maps to PHPstring.int: StandardINTEGER. Maps to PHPint.float: StandardDECIMALorFLOAT. Maps to PHPfloat.bool: StandardTINYINT(1)orBOOLEAN. Maps to PHPbool.uuid: Character length 36VARCHAR(36). Maps to PHPstring.
Nullable Types
Appending a ? to any type marks it as optional/nullable.
int?-> mapped to SQLINTEGER NULL-> mapped to PHP?int.
Modifiers (Annotations)
Modifiers are appended to the type definition using the @ symbol:
@primary: Marks the field as thePRIMARY KEY.@unique: Applies aUNIQUEconstraint to the SQL column.
Relationships (Foreign Keys)
FW does not dynamically load relations like Eloquent (e.g., $user->posts). This design actively prevents hidden queries.
To define a schema relationship:
yaml
Post:
id: int @primary
title: string
user_id: int @foreign(User.id)@foreign(Entity.column): Generates an SQL Application-Level Foreign Key constraint in the migrations.
When querying relationships, the developer must explicitly define a repository method (e.g., findWithPosts(int $userId)) that performs a JOIN and returns an aggregate array of PostModel DTOs.