【发布时间】:2015-10-18 18:22:57
【问题描述】:
如何在 Silex 中使用 html 文件视图。
我正在尝试将 silex 与一些自定义 php 代码一起使用,其中控制器方法包括视图文件。
这是我所拥有的:在我的 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。而且我暂时不想使用twig。
这是我得到的错误:
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 我添加了收到的错误消息。
-
@u_mulder 我不明白你的评论。这是一个问题吗?