Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Target [App\Http\Controllers\Controller] is not instantiable."

I'm trying to follow laracasts tutorial on laravel fundamentals but after getting composer and laravel installed with no problems I can't get my routes file to work with the controller I've reinstalled laravel copied it exactly how laracasts has his but still nothing, anyone see anything wrong with these two files?

routes.php files

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', 'Controller@index');
Route::get('contact', 'Controller@contact');

controller.php file

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

abstract class Controller extends BaseController
{
    use DispatchesJobs, ValidatesRequests;

    public function ___construct()
    {
        $this->middleware('guest');
    }

    public function index()
    {
        return 'hello world!';
    }

    public function contact()
    {
     return 'Contact me!';
    }
}

I have it hosted on localhost:8888 using phps server command if that is any help.

like image 875
Jamie Brown Avatar asked Jul 16 '15 10:07

Jamie Brown


1 Answers

The reason might be that your controller class is abstract, hence it's not instantiable. Remove the abstract keyword.

like image 109
jedrzej.kurylo Avatar answered Oct 09 '22 14:10

jedrzej.kurylo