私は Zend フレームワークの初心者です。Netbeans でサンプル プロジェクトを作成しました。index.phtml を表示して適切に動作しています。しかし、コントローラーを呼び出す必要があります。私が試したことは以下のとおりです。
IndexController.php
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
}
public function indexAction()
{
firstExample::indexAction();
}
}
そして、index.phtml(空のファイルのみ)のすべてのコンテンツを削除しました。このビューをレンダリングしたくないからです。私のカスタムコントローラーは次のとおりです。
firstExampleController.php
<?php
class firstExample extends Zend_Controller_Action{
public function indexAction(){
self::sum();
}
public function sum(){
$this->view->x=2;
$this->view->y=4;
$this->view->sum=x + y;
}
}
?>
firstExample.phtml
<?php
echo 'hi';
echo $this->view->sum();
?>
firstExample.php で sum メソッドを表示する方法。
以下のURLにアクセスすると、空白のページが表示されます。
http://localhost/zendWithNetbeans/public/
上記の URL にアクセスした後、実行は最初に public フォルダー内の index.php に移動すると思います。また、index.php の内容は変更していません。