Alexander Solonik
Alexander Solonik

Reputation: 10230

Controller not found error in laravel . Why?

I have the following controller in my laravel application:

<?php

namespace Http\Controllers;
use App\Http\Requests;
use App\Http\Requests\PrepareNoticeRequest;
use App\Provider;
use Illuminate\Http\Request;

class NoticesController extends Controller {

    public function create() {
        $providers = Provider::lists('name' , 'id');
        return view('notices.create' , compact('providers'));
    }

}

And the following route set in the routes.php file:

Route::get('notices/create' , 'NoticesController@create');

Now when i hit the following URL in the browser:

http://localhost:8080/laravelApp/public/notices/create

I get the following error on my screen:

enter image description here

Why am i getting a controller not found error when i already have a controller ??

Upvotes: 1

Views: 2086

Answers (2)

Alexey Mezenin
Alexey Mezenin

Reputation: 163768

You're using wrong namespace:

namespace App\Http\Controllers;

Also, you missed this:

use App\Http\Controllers\Controller;

You should use php artisan make:controller SomeController command to create controllers if you want to avoid this kind of problem.

Upvotes: 3

Nutshell
Nutshell

Reputation: 8537

Try to change your namespace value to this :

namespace App\Http\Controllers;

And add the following line :

use App\Http\Controllers\Controller;

Hope it helps.

Upvotes: 1

Related Questions