Target class [App\Http\Controllers\welcome] does not exist. error in laravel 6

Viewed 8590

I am getting Target class [App\Http\Controllers\welcome] does not exist error in laravel 6. everything seems okay.

in routes/web.php

Route::get('/','welcome@index');

Welcome.php file everything was working fine on localhost but when I uploaded on the server getting that error.

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Constant_model;



class Welcome extends Controller
{
public function index(){

      $snippets = Constant_model::getDataAllWithLimit('snippets',"id",'DESC',10);

      $data = array(
        'title'=>'Mytitle',
        'description'=>'Hello',
        'seo_keywords'=>'',
        'snippets'=>$snippets

        );

       return view('welcome',$data);    
 }
 }
1 Answers

Since your controller class is named Welcome, your route parameter should be spelled identically, including capitalization:

Route::get('/','welcome@index');

Should be:

Route::get('/','Welcome@index');

Traditionally, Unix-like operating systems treat file case-sensitively while Microsoft Windows is case-insensitive.

That's why it worked on your local environment (you probably have a Windows machine) but failed on your server (likely running Linux).

Related