简体   繁体   中英

Laravel 4: Controller Method Not Found

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!

If you want to hit

http://localhost/laravel/public/vehicles

then

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM