Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Iam new to laravel 9 and iam getting this error

Target class [Countries\CountryController] does not exist.

this is web.php

PHP
<?php

use Illuminate\Support\Facades\Route;

Auth::routes();

Route::group(['middleware'=>['guest']],function(){
    Route::get('/', function()
    {
        return view('auth.login');
    });
});

Route::group(
    [
        'prefix' => LaravelLocalization::setLocale(),
        'middleware' => [ 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath','auth' ]
    ], function(){ 
        Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index'])->name('dashboard');

        Route::group(['namespace' => 'Countries'], function() {
            Route::resource('Countries', 'CountryController');
        });
    });



Controller has been put in another folder app\Http\Controllers\Countries

PHP
<?php 

namespace App\Http\Controllers\Countries;

use Illuminate\Http\Request;

class CountryController extends Controller 
{
  /**
   * Display a listing of the resource.
   *
   * @return Response
   */
  public function index()
  {
    return view(admin.content.countries);
  }  
}

?>


i tries to add this in route file but still the same error coming

use App\Http\Controllers\Countries;

What I have tried:

i tries to add this in route file but still the same error coming

use App\Http\Controllers\Countries;
Posted
Comments
Thava Rajan 17-Aug-22 21:06pm    
In Route change the namespace Countries to
App\Http\Controllers\Countries
khalid4775 21-Aug-22 4:10am    
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900