3
我有一個問題,當我想嘗試用樹枝視圖執行苗條。
錯誤:錯誤,當嘗試在苗條使用樹枝,致命錯誤:TwigView :: getEnvironment()
Fatal error: TwigView::getEnvironment() [function.require]: Failed opening required '/Autoloader.php' (include_path='.:/opt/local/etc/php5') in /opt/local/apache2/htdocs/slim/Slim-Extras/Views/TwigView.php on line 87
這是我的代碼
require '/opt/local/apache2/htdocs/slim/Slim/Slim.php';
17 require '/opt/local/apache2/htdocs/slim/Slim-Extras/Views/TwigView.php';
18 /*
19 * initialize slim to use TwigView Handler
20 */
21 $app = new Slim(array(
22 'view'=> new TwigView()
23));
24 //$app->init(array('view' => 'TwigView'));
25 $app->get('/',function() use ($app){
26 $title = "hi there are new twig";
27 $body = "and this is body maybe you are have idea for this content...:)";
28 $data = array('title' => $title, 'body' => $body);
29 $app->view()->setData(array('title' => $title, 'body' => $body));
30 $app->render('TopPage.html');
31 // echo "hai you are coll man";
32
33 });
34 $app->get('/hello/',function(){
35 echo 'Hello' ;
36 });
37 $app->get('/hello/:name',function($name){
38 echo "yaay...exellent ".$name;
39 });
40 $app->run();
什麼建議嗎?我不知道爲什麼我有這樣的錯誤。
做得更好樹枝目錄例如:'require_once」 ../vendor/autoload.php 「; \ Slim \ Extras \ Views \ Twig :: $ twigDirectory ='../vendor/twig/lib/Twig'; \ Slim \ Extras \ Views \ Twig :: $ twigExtensions = array( \t'Twig_Extensions_Slim', );' – Tim
@Tim'PHP致命錯誤:訪問未聲明的靜態屬性:Slim \\ Views \\ Twig :: $ twigDirectory' – ehime
請提出新的問題,因此您也可以發表一些代碼。 – Tim