E
E
elailasou2015-06-18 21:39:37
Laravel
elailasou, 2015-06-18 21:39:37

How to make routing and controllers work in laravel?

I started learning Laravel, installed version 5.1, I did everything according to the instructions:
laravel.com/docs/master/controllers#basic-controllers
An error occurs at localhost/blog/user/1 :

ReflectionException in Container.php line 736:
Class App\Http\Controllers\UserController does not exist

Root routing works:
Route::get('/', function () {
    return 'Hello world!';
});

My controller:
<?php

namespace App\Http\Controllers;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return Response
     */
    public function showProfile($id)
    {
        return view('user.profile', ['user' => User::findOrFail($id)]);
    }
}

My route:
Route::get('user/{id}', '[email protected]');

The controller is saved in app/Http/Controllers under the name Controller.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2015-06-18
@junk1114

You write "The controller is saved in app/Http/Controllers as Controller.php" but you are referring to "UserController". I guess that's the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question