Laravel控制器不存在
我想重定向到我的控制器而不是视图,但它说:“目标类[app/http/controllers/myFirstController]不存在。”
这是代码(web.php file):
//just a view
Route::get('/', function () {
return view('index');
});
//just a view
Route::get('/final', function () {
return view('welcome');
});
//the controller is interested in
Route::get('/hello-controller', 'app/Http/Controllers/MyFirstController@index');
controller code(app/http/controllers) /myfirstcontroller.php):
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MyFirstController extends Controller
{
public function index(){
return "viva";
}
}
其他信息: Laravel框架版本:8.83.17 PHP版本:PHP 7.4.29
I wanna redirect to my controller instead of a view but it says: "Target class [app/Http/Controllers/MyFirstController] does not exist. "
here is the code (web.php file):
//just a view
Route::get('/', function () {
return view('index');
});
//just a view
Route::get('/final', function () {
return view('welcome');
});
//the controller is interested in
Route::get('/hello-controller', 'app/Http/Controllers/MyFirstController@index');
Controller code (app/Http/controllers/MyFirstController.php) :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MyFirstController extends Controller
{
public function index(){
return "viva";
}
}
additional information:
Laravel Framework version: 8.83.17
PHP version : PHP 7.4.29
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
名称空间是不正确的:资本A用于应用程序,并使用
\
而不是/
,甚至更好:
The namespace is not correct: Capital A for App and use
\
instead of/
or even better :
尝试通过使用来清除控制器的缓存
,也许您应该使用
try to clear cache your controller by using
and also maybe u should use