2013-12-16 103 views
2

我有這段代碼但是我的方法找不到?laravel 4.1控制器方法....找不到

Route.php

Route::controller('Basic', 'BasicController'); 

BasicController.php

class BasicController extends BaseController { 

    public function getIndex() 
    { 
     return View::make('hello'); 
    } 

    public function getTest() 
    { 
     return 'test'; 
    } 
} 
當我打電話從瀏覽器測試

:`http://mydomain.dev/Basic/Test不起作用!
和得到這個錯誤:

的Symfony \分量\ HttpKernel \異常\ NotFoundHttpException
控制方法[測試]未找到。

open: /var/www/mydomain.dev/vendor/laravel/framework/src/Illuminate/Routing/Controller.php 
* @param array $parameters 
* @return mixed 
* 
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException 
*/ 
public function missingMethod($method, $parameters = array()) 
{ 
    throw new NotFoundHttpException("Controller method [{$method}] not found."); 
} 

爲什麼?

我laravel版本是4.1.8

+0

我的索引方法是工作! – Mohammad

+0

你有沒有試過'http:// mydomain.dev/Basic/test'? –

+0

你真的發送請求到控制器嗎? – Zarathuztra

回答

4

如果執行

artisan routes 

你可能會看到這些路由

+--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+ 
| Domain | URI             | Name  | Action       | Before Filters | After Filters | 
+--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+ 
|  | GET Basic/index/{one?}/{two?}/{three?}/{four?}/{five?} |   | [email protected]  |    |    | 
|  | GET Basic            |   | [email protected]  |    |    | 
|  | GET Basic/test/{one?}/{two?}/{three?}/{four?}/{five?} |   | [email protected]  |    |    | 
|  | GET Basic/{_missing}         |   | [email protected] |    |    | 
|  | GET test            |   | Closure      |    |    | 

如果你說你的索引工作:

所以你需要點擊路線

http://mydomain.dev/Basic/test 

http://mydomain.dev/Basic/Test 
+0

我嘗試通過測試和測試,但不工作:( – Mohammad

+1

工作在這裏,測試使用你的代碼和'artisan routes'? –

+0

我認爲是一個bug:https://github.com/laravel/framework/pull/2850 – Mohammad