如何在Silex中使用html文件视图。在silex中调用html(php文件)
我想用一些自定义的php代码,其中控制器方法包括视图文件使用silex。
以下是我有:在我的index.php
$app->get('/', function (Request $request) {
$homeController = new HomeController($request);
$output = $homeController->show($request);
return new Response($output);
});
$app->run();
这里是我的控制器的显示方法:
ob_start();
include "view/start.html.php";
include "view/header.html.php";
include "view/contact.html.php";
include "view/footer.html.php";
include "view/end.html.php";
return ob_end_clean();
有没有一种方法,使这项工作?
我不想将从控制器显示的视图的逻辑移动到index.php。而且我现在也不想用树枝。
这里是错误,我得到:
UnexpectedValueException in Response.php line 403: The Response content must be a string or object implementing __toString(), "boolean" given.
感谢
'return new Response($ output);'? –
什么不起作用?有什么问题?我无法理解。 –
@ AI.G我添加了我得到的错误信息。 –