2013-06-25 87 views
0

當我是很新,laravel和我有問題,我在routes.php文件的路由handleRoutingException錯誤路由寧靜控制器

Route::controller('users', 'userController'); 

我有一個在我的控制器,目錄名爲userController.php文件

UserController的:

<?php 

class userController extends BaseController { 
public $restful = true ; 


    public function index() 
    { 
     echo 'hello'; 
    } 
    public function check() 
    { 
     echo 'check'; 
    } 
} 

當我運行http://localhost/larave/public/users

我得到NotFoundHttpException

Symfony\Component\HttpKernel\Exception\NotFoundHttpException 
…\bootstrap\compiled.php4921 
Illuminate\Routing\Router handleRoutingException 
…\bootstrap\compiled.php4766 
Illuminate\Routing\Router findRoute 
…\bootstrap\compiled.php4754 
Illuminate\Routing\Router dispatch 
…\bootstrap\compiled.php481 
Illuminate\Foundation\Application dispatch 
…\bootstrap\compiled.php470 
Illuminate\Foundation\Application run 
…\public\index.php49 

有什麼不對?當我做路由每個控制器/動作像

Route::get('users/check', '[email protected]');

+0

你是你使用的是什麼版本的標記這是laravel和laravel 4 ..? –

回答

0

REST風格的控制器方法需要使用HTTP動詞前綴..如getpost它工作正常。

例子:

class userController extends BaseController { 
    public function getIndex() { 
    return "I am echoing only when you GET me!"; 
    } 

    public function postIndex() { 
    return "I am echoing only when you POST to me!"; 
    } 
}