路由中的反射异常.php第 335 行:函数 () 不存在不知道为什么



我正在学习Laravel框架,我已经创建了一个简单的项目。

这是我的代码:

web.php

Route::get('/', function () {
return view('welcome');
});
Route::get('/people', ['uses' => 'PeopleController@index']);

PeopleController.php

class PeopleController extends Controller
{
public function index()
{
$users = [
'0' =>[
'first' => 'Alex',
'last' => 'Shifu',
'location' => 'Gotham'
]
];
return view('people.index' , compact('people'));
}
}

index.blade.php

@foreach($people as $peep)
<li>{!! $peep['first'] !!}</li>
@endforeach

这些是我面临的错误:

在RouteCollection.php的第161行Router.php第766行的RouteCollection->match(object(Request))Router->Router.php第621行中的findRoute(object(Request))Router->Router.php第607行中的dispatchToRoute(对象(请求))路由器->调度(对象(请求))在Kernel.php第268行内核->Illuminate\Foundation\Http{closure}(对象(请求))管线.php管线53中的管道->照明\路由{closure}(对象(请求))Check ForMaintenanceMode.php第46行,位于CheckForMaintenanceMode->中的句柄(对象(请求),对象(关闭))管线.php管线137管道->照明\中的管道{closure(对象(请求))管线.php管线33中的管道->照明\路由{closure}(对象(请求))Pipeline.php在Pipeline->中的第104行,然后在Kernel.php中的(对象(闭包))中Kernel->sendRequestThroughRouter(object(Request))处的第150行index.php中Kernel->handle(object(Request))处的Kernel.php第117行第54行require_one('C:\wamp64\www\MyApp\public\index.php')server.php第21行

我看到的唯一问题是,您必须在index()方法中将$users更改为$people。

除此之外,一切看起来都很好。