猿问

lavarel找不到控制器如何解决?

路由是这么写的:Route::get('student/index',['uses' => 'StudentController@index']);


控制器StudentController.php


<?php
namespace App\Http\Controller;

use App\Http\Controllers\Controller;

class StudentController extends Controller
{
   public function index()
   {
       return view('student.index');
   }
}

结果提示:

Whoops, looks like something went wrong.

1/1                            ReflectionExceptionin Route.php line 264:                            Class App\Http\Controllers\StudentController does not exist                        

in Route.php line 264

atReflectionMethod->__construct('App\Http\Controllers\StudentController', 'index') in Route.php line 264

atRoute->signatureParameters('Illuminate\Database\Eloquent\Model') in Router.php line 859

atRouter->substituteImplicitBindings(object(Route)) in Router.php line 844

atRouter->substituteBindings(object(Route)) in Router.php line 827

atRouter->findRoute(object(Request)) in Router.php line 691

atRouter->dispatchToRoute(object(Request)) in Router.php line 675


qq_卡卡_35
浏览 1987回答 1
1回答

qq_卡卡_35

命名空间写错了,应该是namespace App\Http\Controllers;
随时随地看视频慕课网APP
我要回答