#Laravel error Target class [Controllers\Example] does not exist.

1 messages · Page 1 of 1 (latest)

chilly summit
#

#rules:

1️⃣ Help us help you - Search the documentation before posting your issue and explain what you're doing and include any error messages you have received.

oblique tinsel
#

ok i did my friend

#

Laravel error Target class [Controllers\Example] does not exist.

#

and this is the code


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class Sam extends Controller
{
    public function showString()
    {
        return 'Hello';
    }
}```
#

this is the controller file

chilly summit
#

Your issue is with routing.

oblique tinsel
#

and this is the route file


use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});


route::get('second', 'Controllers\Sam@showString');
#

can you explain more

chilly summit
oblique tinsel
#

wait i can't do it as a string in Laravel?

chilly summit
#

You also need to take care with naming. It’s Route::get, not all-lowercase route::get

oblique tinsel
#

you might be right because im learning in the old version of laravel but i didn't think its gonna be an issue

chilly summit
#

#

Why are you learning in an old version?

#

Things change. As you have found.

oblique tinsel
#

becaue the course that im learing at that was before 2 years ago i think

chilly summit
#

#

Just read the official docs.

#

They’re up to date.

oblique tinsel
#

do you recomend a new course talks about the new version of laravel

chilly summit
#

Just read the official docs.

oblique tinsel
#

okay so i can't show a string in the new version of laravel