路由restful控制器时handleRoutingException错误

时间:2013-06-25 15:01:08

标签: laravel laravel-4

我对laravel很新,我遇到路由问题

在我的routes.php中

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', 'userController@check');

1 个答案:

答案 0 :(得分:0)

RESTful控制器方法需要以HTTP VERB为前缀..例如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!";
  }
}