[英]Target class [PostController] does not exist
I've looked through different questions posted on SO but still wasn't able to find a solution to my problem.我查看了发布在 SO 上的不同问题,但仍然无法找到解决我的问题的方法。
My PostController.php controller:我的 PostController.php 控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PostController extends Controller
{
public function index() {
$posts = Post::all();
return view("posts.index", compact("posts"));
}
}
And when I go to the browser I get this error: Target class [PostController] does not exist.当我转到浏览器时,出现此错误:目标类 [PostController] 不存在。
I've seen other questions on SO like mine and tried several solutions suggested我已经看到像我这样的其他问题,并尝试了几种建议的解决方案
What else could be a problem?还有什么问题?
Any help would be really appriciated!任何帮助都会非常感谢!
UPD 0: Thank you for the reply, @Tithira. UPD 0:感谢您的回复,@Tithira。 I tried to add
我试着添加
use App\\Http\\Controllers\\PostController;
in my web.php file在我的 web.php 文件中
And now I'm getting this error:现在我收到此错误:
Error
Class 'App\Http\Controllers\Post' not found
UPD 1: I tried to wirte path to my controller with the word app
starting with a lowercase letter. UPD 1:我尝试使用以小写字母开头的单词
app
写入控制器的路径。 And now I'm getting this error:现在我收到此错误:
Illuminate\Contracts\Container\BindingResolutionException
Target class [app\Http\Controllers\PostController] does not exist.
pls try请试试
php artisan optimize:clear php工匠优化:清除
and和
composer dumpautoload作曲家转储自动加载
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.