dounabi6295 2014-04-01 19: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 19:59
    关注

    If you want to hit

    http://localhost/laravel/public/vehicles
    

    then

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

报告相同问题?

悬赏问题

  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试