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

  • 写回答

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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化