2014-10-09 28 views
0

我對MVC並不陌生,但對Laravel來說是新手。我已經設法在Windows 8.1上安裝WAMP。我轉到根URL(http://localhost/public/)並獲取Laravel徽標和「您已抵達」。文本行。Laravel - 通往封閉的路線

現在我想玩點兒,the documentation告訴我,下面的代碼應該工作。

<?php 

/* 
|-------------------------------------------------------------------------- 
| Application Routes 
|-------------------------------------------------------------------------- 
| 
| Here is where you can register all of the routes for an application. 
| It's a breeze. Simply tell Laravel the URIs it should respond to 
| and give it the Closure to execute when that URI is requested. 
| 
*/ 

Route::get('/', function() 
{ 
    return View::make('hello'); 
}); 

Route::get('users', function() { 
    return 'users!'; 
}); 

我應該得到的文本users,當我瀏覽到http://localhost/public/users,而不是我得到一個404什麼是我做錯了什麼?

+0

你的代碼沒有問題 – 2014-10-09 12:08:11

+0

嗯爲什麼我會得到404?在我做出改變後,我是否需要重新運行某些東西? – Ciwan 2014-10-09 12:08:59

+0

您是否按照http://laravel.com/docs/4.2/installation#pretty-urls設置了您的Web服務器? – ceejayoz 2014-10-09 12:09:56

回答

1

你的路由文件的代碼應該是這樣的

Route::get('/users', function() { 
    return 'users!'; 
}); 

試試看吧!

+0

工作,奇怪的是文檔沒有提到預斜槓。謝謝。 – Ciwan 2014-10-09 12:22:02