php - 当我运行项目时,它显示控制器没有在 laravel 中退出,但它在控制器文件夹中我该怎么办?
问题描述
SampleController.php、web.php、example.blade.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SampleController extends Controller
{
public function index(){
return view('example');
}
}
网页.php
<?php
use Illuminate\Support\Facades\Route;
Route::get('/',function () {
return view('welcome');
});
Route::get('/sample', 'SampleController@index');
例子.blade.php
<?php
echo 'hello world !!';
?>
解决方案
我希望你正在使用 Laravel 8 并且它现在已经更新了,
use App\Http\Controllers\SampleController;
Route::get('/sample', [SampleController::class, 'index']);
请在此处查看更多详细信息, https://laravel.com/docs/8.x/routing
推荐阅读
- knockout.js - 使用数据表分页的数据绑定在 knockout.js 中不起作用
- java - 如何在 Java 项目中管理证书、信任库和密钥库密钥文件
- sql - 有没有办法返回给定行中的所有唯一值
- javascript - 动态下拉菜单的高度为 0
- java - java.io.IOException: No FileSystem for scheme: abfs for adls-gen 2 in spark java
- javascript - 如何根据Angular中的按钮类更改点击功能
- r - 如何根据来自另一个数据帧的许多行来查找数据帧中的一行的匹配项
- javascript - 如何在coldfusion中通过JQuery循环和显示表中的SQL数据
- elasticsearch - Elasticsearch 查询每小时范围无法正常工作
- sql - 如何从 Firebird DB 中读取所有“last_changed”记录?