Ethna
About
PHPのMVC系のフレームワーク。
開発終了済み。
動作概要 - Ethna - PHPウェブアプリケーションフレームワーク
最新版はv2.6だが文書類が放棄されている。
v2.5系の古い公式サイト「PukiWiki」の方が文書が整理されているので、これを参考にする。
Tutorial
Action/View/Template
2. アクション、ビュー、テンプレートの作成と処理の流れ — Ethna 2.6 documentation
actionクラス内にフォーム定義のActionFormと実際の処理のActionClassを記載する。
<?php class Miniblog_Form_Hello extends Miniblog_ActionForm { protected $form = array( ); } class Miniblog_Action_Hello extends Miniblog_ActionClass { public function prepare() { return null; } public function perform() { return 'hello'; } }
prepareでバリデーション系処理を行い、performで実処理を行う。
returnで遷移先の画面名のstringを返す。
prepareでreturn null以外が返ると、performは実行されずに終わる。
ActionClassはクラス名の命名規則から該当するActionFormのプロパティーのデータを保有している模様。
ActionClass
https://chatgpt.com/c/67c160a8-5250-800b-bbf6-2c8cc947e954
ActionClass — Ethna 2.6 documentation
ActionClassではprepareで値を検証し、performで実行する。
performの戻り値が遷移先名となる。遷移先名のViewClassやTemplateが呼び出される。nullを返した場合、遷移しない、つまりActionClassが実行された際のルーティングに対応するView/Templateが呼ばれる。
基本はreturn nullでも問題ない。
Debug
Ethna でのログ出力を制御する - Ethna - PHPウェブアプリケーションフレームワーク
logging
Ethna_Loggerクラスを使ってログを管理している。