Zend framework 从ZEND Framework中IndexController中的indexAction()开始执行

Zend framework 从ZEND Framework中IndexController中的indexAction()开始执行,zend-framework,Zend Framework,在IndexController的indexAction()方法中,我调用了model方法,该方法从数据库返回员工列表(employeeList)。然后将此employeeList添加到$view,然后调用$view->render('index.phtml')和index。phtml显示员工列表。代码如下: IndexController.php <?php require_once('../Zend/Controller/Action.php'); require_once('../

在IndexController的indexAction()方法中,我调用了model方法,该方法从数据库返回员工列表(employeeList)。然后将此employeeList添加到$view,然后调用$view->render('index.phtml')和index。phtml显示员工列表。代码如下:

IndexController.php

<?php

require_once('../Zend/Controller/Action.php');
require_once('../models/HRModel.php');
require_once('../Zend/View.php');

class IndexController extends Zend_Controller_Action
{
 protected $hrModel;

     public function init()
     {
            $this->hrModel = new Application_Model_HRModel();

     }

     public function indexAction()
     {
           $view = new Zend_View(array('scriptPath' =>'../views'));
           $view->employeeList = $this->hrModel->queryAllEmployees();
           echo $view->render('index.phtml');

     }


 }

现在我想从indexAction()方法开始执行。但是如何执行?在浏览器中输入的url应该是什么?在请求参数中,控制器将是IndexController,操作将是indexAction。因此,请帮助我解决此问题。

要执行此操作,您需要使用索引操作调用索引控制器。因此,您可以使用www.foo.bar/index/index或简单的www.foo.bar。 如果这不起作用,您的配置可能有错误

还是我弄错了你的问题


您是如何配置PHP错误处理的?可能您有一个未显示的PHP错误。

在哪里设置文档根ZF?在我的项目中,在应用程序文件夹中有4个文件夹,分别命名为configs、Controller、models、,视图。在库文件夹中,我包含了包含所有Zend framework类的Zend文件夹。因为我必须从索引控制器开始,所以我将web根设置为应用程序/控制器,并在运行配置中将项目url设置为其中控制器为索引,操作为索引。当我在浏览器中运行时,它显示为“警告:需要\u一次”(../Zend/Controller/Action.php)[function.require once]:无法打开流:您必须将文档根目录设置为public并转到页面:
localhost:8888
,但我建议您阅读以下内容:谢谢回复。我现在已将其设置为application/public。但仍然会出现相同的问题。我也已在apache httpd中设置了文档根目录,并且我已阅读了您提供的手册并应用了所有内容,但。。。。。。当我在浏览器中请求url localhost:8888/Index/Index时,它会显示警告:require_once(../Zend/Controller/Action.php)[function.require once]:无法打开流:在第2行的C:\Users\398853\Documents\NetBeansProjects\PhpProject3\application\controllers\IndexController.php中没有这样的文件或目录,我已将所有Zend类包含在库文件夹中(因为我正在使用netbeans)。因为我必须从索引控制器开始,所以我将web根设置为应用程序/控制器,并在运行配置中将项目url设置为localhost:8888/Index/Index,其中控制器是索引,操作是索引。还必须做什么?主要的是我必须从索引控制器开始执行,从该控制器开始,我应用$view->render('index.phtml')。所以从indexcontroller的indexAction()方法开始执行。感谢您的回复。为什么不使用Zend的自动加载函数来包含所有必需的文件呢?
<?php
require_once('Zend/Db.php');
require_once('Zend/Config/Ini.php');
class Application_Model_HRModel
{
   protected $db=null;

   public function queryAllEmployees() {

   return $this->db->fetchAssoc("select comment from guestbook");

}
foreach ($this->employeeList as $emp):
extract($emp);

echo '$EMPLOYEE_ID';

echo $comment;

endforeach