[英]ReflectionException in Route.php line 335: Function () does not exist
[英]ReflectionException in Route.php line 335: Function () does not exist don't know why
我正在學習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
這些是我面臨的錯誤:
在RouterCollection.php第161行的RouteCollection-> match(對象(請求))在Router.xp第766行的Router-> findRoute(對象(請求))在Router.php第621行的Router-> dispatchToRoute(對象(請求)) )在Pipeline.php第607行的Router-> dispatch(對象(Request))中的Kernel.php第268行的Kernel-> Illuminate \\ Foundation \\ Http {closure}(object(Request))在Pipeline.php第53行的Pipeline - >在Pipeline-> Illuminate \\ Pipeline {中的Pipeline.php第137行的CheckForMaintenanceMode-> handle(object(Request),object(Closure))中的CheckForMaintenanceMode.php第46行中的Illuminate \\ Routing {closure}(object(Request)) Pipeline中的Pipeline-> Illuminate \\ Routing {closure}(對象(Request))中的Pipeline-> then(對象(Closure))中的Pipeline.php第33行中的pipe}(對象(Request))。 PHP行150在Kernel-> sendRequestThroughRouter(對象(請求))在Kernel.php第117行的Kernel-> handle(對象(Request))在index.php第54行的require_once('C:\\ wamp64 \\ www \\ MyApp \\ server.php第21行中的public \\ index.php')
我看到的唯一問題是你必須在index()方法中將$ users更改為$ people。
除此之外,一切看起來都很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.