Barry Tormey
Barry Tormey

Reputation: 3126

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!

Upvotes: 2

Views: 294

Answers (1)

Jarek Tkaczyk
Jarek Tkaczyk

Reputation: 81167

If you want to hit

http://localhost/laravel/public/vehicles

then

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

Upvotes: 4

Related Questions