문제

I'm new to Laravel, I have a route in my routes.php file like this:

    <?php
Route::resource('search', 'SearchController');                
?>

and I have the controller app/controllers/SearchController.php that looks like this:

<?php

    class SearchController extends \BaseController {

        protected $layout = 'layouts.master';
        public function create() {}

        public function store(){}

        public function index(){
            return View::make('hello');
        }
    }
    ?>

I previously had a controller with unrestful methods name SearchController. I renamed that one to OldSearchController and updated the routes.

and a file hello.php in app/views.

but, whenever I try to access the page via http://localhost/search, I get the following error:

BadMethodCallException 
Method [index] does not exist.

what else needs to be done?

도움이 되었습니까?

해결책 2

As I said in the comments, the following command did the trick:

php artisan dump-autoload

Probably something happened during the installation.

다른 팁

All you need to do is run this:

composer dump-autoload

Your classes are being cached and there is likely a conflict going on with your previous SearchController.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top