0

私はlaravelにかなり慣れていないので、ルーティングに問題があります

私のroutes.phpで

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

userController.phpcontrollers ディレクトリにファイルがあります

ユーザーコントローラー:

<?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

getRESTful コントローラー メソッドには、やなどの HTTP VERB.. をプレフィックスとして付ける必要がありますpost

例:

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 に答える