dounabi6295 2014-04-01 11:51
浏览 98
已采纳

Laravel 4:找不到控制器方法

I'm brand new to Laravel 4 and just trying to get started. I can't seem to get the routes and controllers to work nicely together.

I am trying to navigate to:

http://localhost/laravel/public/vehicles

Using the controller VehiclesController.php

<?php

class VehiclesController extends BaseController {

public $restful = true;

public function getIndex() {
    return View::make('vehicles.index');
}
}

and the route

Route::controller('/', 'VehiclesController');

I have a view created in views\vehicles\index.php which only contains HTML.

Here is my routes table:

+--------+-------------------------------------------------------+------+----------------------------------+----------------+---------------+
| Domain | URI                                                   | Name | Action                           | Before Filters | After Filters |
+--------+-------------------------------------------------------+------+----------------------------------+----------------+---------------+
|        | GET|HEAD /                                            |      | VehiclesController@getIndex      |                |               |
|        | GET|HEAD index/{one?}/{two?}/{three?}/{four?}/{five?} |      | VehiclesController@getIndex      |                |               |
|        | GET|HEAD|POST|PUT|PATCH|DELETE {_missing}             |      | VehiclesController@missingMethod |                |               |
+--------+-------------------------------------------------------+------+----------------------------------+----------------+---------------+

I have looked at other posts and still can't quite figure out where I am going wrong. Thanks!

  • 写回答

1条回答 默认 最新

  • duanlongling5308 2014-04-01 11:59
    关注

    If you want to hit

    http://localhost/laravel/public/vehicles
    

    then

    Route::controller('/vehicles', 'VehiclesController');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

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

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

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

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

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

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

客服 返回
顶部