我是Laravel 4的新手,只是想开始吧。我似乎无法让路线和控制器很好地协同工作。
我正试图导航到:
http://localhost/laravel/public/vehicles
使用控制器 VehiclesController.php
<?php
class VehiclesController extends BaseController {
public $restful = true;
public function getIndex() {
return View::make('vehicles.index');
}
}
和路线
Route::controller('/', 'VehiclesController');
我在views\vehicles\index.php
中创建了一个仅包含HTML的视图。
这是我的路线表:
+--------+-------------------------------------------------------+------+----------------------------------+----------------+---------------+
| 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 | | |
+--------+-------------------------------------------------------+------+----------------------------------+----------------+---------------+
我查看了其他帖子,仍然无法弄清楚我哪里出错了。谢谢!
答案 0 :(得分:4)
如果你想点击
http://localhost/laravel/public/vehicles
然后
Route::controller('/vehicles', 'VehiclesController');