0

我对 laravel 很陌生,我在路由上有问题

在我的 routes.php 中

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

我有一个文件userController.php在我的控制器目录中调用

用户控制器:

<?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');

4

1 回答 1

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!";
  }
}
于 2013-06-25T19:25:02.217 回答