I've looked through different questions posted on SO but still wasn't able to find a solution to my problem.
My PostController.php controller:
<?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.
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. I tried to adduse App\\Http\\Controllers\\PostController;
in my web.php file
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. 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
and
composer dumpautoload
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.