0

hello im newbie in laravel, i tried to display page in laravel 9.52. i made blade file, resource controller, and call it in routes here is my route:

Route::resource('admin/portfolio', 'PortfolioController');

and here is my controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PortfolioController extends Controller
{
    public function index()
    {
        //
        return view("admin.portfolio");
    }

admin mean is my portfolio blade saved in admin folder views.

i check the spelling file controller name but, there is no problem. i named my controller file as PortfolioController.php but it comes error when i tried to run it: Target class [controller name] does not exist.

witch
  • 1
  • 2
  • 1
    Does this answer your question? [Error “Target class controller does not exist” when using Laravel 8](https://stackoverflow.com/questions/63807930/error-target-class-controller-does-not-exist-when-using-laravel-8) – STA Jul 09 '23 at 06:52

1 Answers1

1

For working on laravel 8, 9 and newer version you will have to modify your route file like below. You will have to import class namespace at the top.

***in web.php***
use namespace App\Http\Controllers\PortfolioController;


Route::resource('admin/portfolio', PortfolioController::class);

or You can also define route by mentioning full namespace path

Route::resource('/users', 'App\Http\Controllers\PortfolioController');
Ariful Islam
  • 696
  • 6
  • 11