我想知道如何手动开始执行我的 MVC 应用程序的控制器操作。我的目标是使用简单的包含将 /myController/myAction 的 html 输出集成到另一个 php 应用程序(typo3)中。我想过手动实例化控制器、视图和布局,以绕过调度程序。可悲的是我无法让它工作。我目前的方法如下所示:
// standard bootstrap ... setting up autoloader, database etc.
$layout = new Zend_Layout();
$layout->setLayoutPath(('/application/default/layouts'));
$layout->setLayout('main');
$layout->setContentKey('content');
$view = new Zend_View();
$controller = new IndexController(new Zend_Controller_Request_Http($currenUrl), new Zend_Controller_Response_Http());
$controller->view = $view;
$controller->init();
$controller->hinweisAction();
$layout->content = $view->render();
echo $layout->render();
实例化布局没问题,但是创建控制器的时候就变得复杂了。在调用构造函数后设置视图实例不起作用,因为在实例化期间已经需要视图。
对于这种情况,什么是“正确”的方式?也许实现一个简单的用户定义调度程序,它使用我预定义的控制器和动作名称?
问候
格奥尔格·瓦赫特