2014-05-24 32 views
1

好吧,我剛剛開始檢查Laravel 4.1,我遇到了一個問題,我不明白爲什麼?問題是我在屏幕上看到這條消息「哎呀,看起來像是出了點問題。」但我沒有做任何事情。我創建了一個視圖,控制器和添加的路線,這是什麼是這些文件「哎呀,看起來像是出了點問題。」 Laravel 4.1

VIEW

<h1>Author's home page</h1> 

控制器

class AuthorsController extends BaseController { 

    public $restful = true; 
    public function getIndex() { 
     return View::make('authors.index'); //authors.index because it's in the authors folder within the views folder 
    } 
} 

ROUTE

Route::get('authors', '[email protected]'); 

因此,邏輯規定,當我轉到作者URL時,它應該在AurhorsController頁面中加載getIndex函數,並顯示在views> authors中的index.blade.php文件。

如果是這樣,那麼我不知道爲什麼這不起作用!任何幫助,將不勝感激。提前致謝。

編輯1

這是實際的錯誤

throw new NotFoundHttpException(); 

EDIT 2

Trace

+7

'「哎呦,看起來像出事了。」'是所有錯誤頁面顯示的通用文本。你能否粘貼實際的錯誤信息(尋找例外)? –

+0

@MarttiLaine我調試關閉,哎呀這是錯誤...拋出新的NotFoundHttpException(); – user3263978

回答

1

您應該刪除public $restful = true;,但它不是下面給出NotFoundHttpException

// Path: app/controllers/AuthorsController.php 
class AuthorsController extends BaseController { 

    // public $restful = true; 

    public function getIndex() { 
     return View::make('authors.index'); 
    } 
} 

問題根據您的route

Route::get('authors', '[email protected]'); 

,如果你犯了一個GET請求,它應該工作,確保你做來自瀏覽器地址欄和url的請求類似於yourdomain.dev/authorshttp://localhost/yourapp/authors。你也可以(項目目錄內),請從命令提示符/終端以下命令:

composer dump-autoload 
+0

啊謝謝你!我現在修復了它,你怎麼說呢刪除public $ restful = true; ? – user3263978

+0

歡迎,是的,爲了聲明[RESTful控制器](http://laravel.com/docs/controllers#restful-controllers)你不需要在控制器中使用'public $ restful = true;',它在'版本3'。 –

+0

啊好吧謝謝你有道理。另一個問題,你碰巧知道如何從URL中刪除公共目錄? – user3263978

1

看起來像Laravel的嘗試訪問公用文件夾和失敗,因爲沒有名爲的文件在該文件夾中,也沒有名爲public/authors的路由。假設您的安裝位於http://localhost:8081/branch,您將想要轉至http://localhost:8081/branch/authors

相關問題