dongsunny1113 2013-12-16 09: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

展开全部

  • 写回答

1条回答 默认 最新

  • duanbu1998 2013-12-16 10: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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部