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