当我运行项目时,它显示控制器并没有在laravel中退出,但它在controllers文件夹中,我该怎么办



SampleController.php,web.php,example.blade.php

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
class SampleController extends Controller
{
public function index(){
return view('example');
}

}

web.php

<?php
use IlluminateSupportFacadesRoute;
Route::get('/',function () {

return view('welcome');
});
Route::get('/sample', 'SampleController@index');

example.blade.php

<?php
echo 'hello world !!';
?>

我希望您使用的是Laravel 8及其现在更新的

use AppHttpControllersSampleController;
Route::get('/sample', [SampleController::class, 'index']);

请在此处查看更多详细信息,https://laravel.com/docs/8.x/routing

最新更新