AGENTS
August 7, 2026 · View on GitHub
Read root AGENTS.md first. Security: SECURITY.md.
Purpose
Database entities via flightphp/active-record only. One table (or clear mapping) per class. Example: Post.
Flight / ActiveRecord nuances (easy to get wrong)
-
Extend
flight\ActiveRecord, not Eloquent, not a custom static base. -
Constructor receives the DB connection (PDO / SimplePdo-compatible):
public function __construct($databaseConnection) { parent::__construct($databaseConnection, 'posts'); } -
Controllers inject
SimplePdo, thennew Post($this->db). Do not hide a global PDO inside the model. -
Table name is the second constructor argument (or options array) — keep it explicit.
-
Document columns with
@propertyPHPDoc for IDEs and agents (@property int $id, etc.). -
Find / save:
$model->find($id),$model->findAll(),$model->save(),$model->insert(),$model->update(),$model->delete(). Prefer library helpers (eq,like,orderBy) over string-concatenated SQL. -
isHydrated()— check afterfind()before trusting properties (seePostController). -
Dirty data / mass assign: use
copyFrom/dirtycarefully; never mass-assign untrusted request arrays without allowlisting fields. -
Relationships — define
$relationsper ActiveRecord docs; do not invent Laravel-stylehasMany()method APIs unless they exist in this library. -
Schema changes belong in
migrations/*.sql, not in model constructors. -
Raw SQL for reports/migrations: inject
SimplePdoin the controller/command — models stay ActiveRecord-centric.
Docs: https://docs.flightphp.com/awesome-plugins/active-record
Do not
- Create a parallel
app/Models+ Eloquent story. - Use deprecated
PdoWrapperas the documented connection type (useSimplePdo). - Interpolate user input into
where("id = {$id}").