dongsunny1113
2013-12-16 17:44
浏览 75
已采纳

laravel 4.1控制器方法......未找到

i have this code but my Method not find ?

Route.php

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

BasicController.php

class BasicController extends BaseController {

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

    public function getTest()
    {
        return 'test';
    }
}

when i call test from browser : `http://mydomain.dev/Basic/Test Not Work !
and get this error :

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method [Test] not found.

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.");
}

Why ?

My laravel version is 4.1.8

图片转代码服务由CSDN问答提供 功能建议

我有这段代码但我的方法找不到?

Route.php

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

BasicController.php

 类BasicController扩展BaseController {
 
公共函数getIndex()
 {
返回View :: make('hello'); 
} 
 
 public 函数getTest()
 {
'返回'test'; 
} 
} 
   
 
 

当我从浏览器调用test时:` http://mydomain.dev/Basic/Test 不起作用!
得到此错误:

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
找不到控制器方法[Test]。

  open:/var/www/mydomain.dev/vendor/laravel/framework/src/Illuminate/Routing/Controller.php
 * @param array $ 参数
 * @return mixed 
 * 
 * @throws \ Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException 
 * / 
 npublic function missingMethod($ method,$ parameters = array())
 {
 throw  new NotFoundHttpException(找不到“控制器方法[{$ method}]。”); 
} 
   
 
 

为什么?

我的laravel版本是4.1.8

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanbu1998 2013-12-16 18:00
    已采纳

    If you execute

    artisan routes
    

    You probably will see those routes

    +--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+
    | Domain | URI                                                    | Name       | Action                         | Before Filters | After Filters |
    +--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+
    |        | GET Basic/index/{one?}/{two?}/{three?}/{four?}/{five?} |            | BasicController@getIndex       |                |               |
    |        | GET Basic                                              |            | BasicController@getIndex       |                |               |
    |        | GET Basic/test/{one?}/{two?}/{three?}/{four?}/{five?}  |            | BasicController@getTest        |                |               |
    |        | GET Basic/{_missing}                                   |            | BasicController@missingMethod  |                |               |
    |        | GET test                                               |            | Closure                        |                |               |
    

    If you say that your index is working:

    So you need hit the route

    http://mydomain.dev/Basic/test
    

    and not

    http://mydomain.dev/Basic/Test
    
    打赏 评论

相关推荐 更多相似问题