如何在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我添加了我得到的錯誤信息。 –