「Ethna」の版間の差分
(Test) |
細 (→Test) |
||
| 79行目: | 79行目: | ||
=== Test === | === Test === | ||
https://chatgpt.com/share/681ac058-9ad4-800b-bf05-6524a757b97a | * [https://qiita.com/sato-takaaki/items/bdcb5136b7055786ba34 EthnaのユニットテストをPHPUnitで書いてみる話 #PHP - Qiita] | ||
* https://chatgpt.com/share/681ac058-9ad4-800b-bf05-6524a757b97a | |||
* https://chatgpt.com/share/68350967-c3d0-800b-aec1-6e2a2623aa28 | |||
2025年5月27日 (火) 09:52時点における最新版
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クラスを使ってログを管理している。
Other
Smartyの取得
Ethnaでsmartyを直接使うメモ - ひとりしずかに。
$smarty = $this->backend->ctl->getTemplateEngine();
これでSmartyインスタンスを取得できる。
$configアプリ設定
開発FAQ - Ethna - PHPウェブアプリケーションフレームワーク
etc/<ProjectName>-ini.php に$configの配列で設定している。
