phplaravelcontrollershared-hostingshared

My laravel project controllers does not exist. why?


I am new to laravel but when I coded in vscode everything worked fine, now when I uploaded it to shared server like hostinger now it does not work It says controller does not exist ...I am using laravel 11 and my php is 8.2 composer is 2

I was thinking it was namespace but id does not look like it... any help?

I tried everything from changing letters and controllers to writing permissions, even asking AI but nothing

web.php

<?php

use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\CategoryController;
use App\Http\Controllers\Admin\MeniuController;
use App\Http\Controllers\Admin\TableController;
use App\Http\Controllers\Admin\UzsakymasController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\Frontend\CategoryController as FrontendCategoryController;
use App\Http\Controllers\Frontend\MeniuController as FrontendMeniuController;
use App\Http\Controllers\Frontend\TableController as FrontendTableController;
use App\Http\Controllers\Frontend\WelcomeController;
use App\Http\Controllers\ProfileController;
use Illuminate\Support\Facades\Route;
use App\Http\Middleware\Admin;

// Frontend routes
Route::get('/', [WelcomeController::class, 'index']);
Route::get('/categories', [FrontendCategoryController::class, 'index'])->name('categories.index');
Route::get('/categories/{category}', [FrontendCategoryController::class, 'show'])->name('categories.show');
Route::get('/menius', [FrontendMeniuController::class, 'index'])->name('menius.index');
Route::get('/menius/{meniu}', [FrontendMeniuController::class, 'show'])->name('menius.show');
Route::get('/table', [FrontendTableController::class, 'index'])->name('table.index');

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

// Authenticated user routes
Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

// Admin routes
Route::middleware(['auth', Admin::class])->prefix('admin')->name('admin.')->group(function () {
    Route::get('/', [AdminController::class, 'index'])->name('index');
    Route::get('/register', [RegisteredUserController::class, 'create'])->name('register');
    Route::post('/register', [RegisteredUserController::class, 'store']);

    Route::resource('categories', CategoryController::class)->names([
        'index' => 'categories.index',
        'create' => 'categories.create',
        'store' => 'categories.store',
        'show' => 'categories.show',
        'edit' => 'categories.edit',
        'update' => 'categories.update',
        'destroy' => 'categories.destroy',
    ]);

    Route::resource('menius', MeniuController::class)->names([
        'index' => 'menius.index',
        'create' => 'menius.create',
        'store' => 'menius.store',
        'show' => 'menius.show',
        'edit' => 'menius.edit',
        'update' => 'menius.update',
        'destroy' => 'menius.destroy',
    ]);

    Route::resource('table', TableController::class)->names([
        'index' => 'table.index',
        'create' => 'table.create',
        'store' => 'table.store',
        'show' => 'table.show',
        'edit' => 'table.edit',
        'update' => 'table.update',
        'destroy' => 'table.destroy',
    ]);

    Route::resource('uzsakymas', UzsakymasController::class)->names([
        'index' => 'uzsakymas.index',
        'create' => 'uzsakymas.create',
        'store' => 'uzsakymas.store',
        'show' => 'uzsakymas.show',
        'edit' => 'uzsakymas.edit',
        'update' => 'uzsakymas.update',
        'destroy' => 'uzsakymas.destroy',
    ]);
});

require __DIR__.'/auth.php';

like my WelcomeController.php

<?php

namespace App\Http\Controllers\FrontEnd;

use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Meniu;
use Illuminate\Http\Request;

class WelcomeController extends Controller
{
    public function index()
    {
        $savaite = Category::where('name', 'Pirma savaite')->first();

        return view('welcome', compact('savaite'));

    }
}

Solution

  • change

    namespace App\Http\Controllers\FrontEnd;
    

    to

    namespace App\Http\Controllers\Frontend;
    

    on your WelcomeController.php