by_ozturk's avatar

[App\Http\Controllers\Admin\AdminController] does not exist.

Hello, I uploaded my Laravel project to the server but I am getting the following error: Target class [App\Http\Controllers\Admin\AdminController] does not exist. There is no problem when running it locally, but when I upload it to the server, I get this error.

0 likes
12 replies
kokoshneta's avatar

Is the file actually there? Is your Composer correctly set up, dependencies installed and up to date?

tykus's avatar

Any chance that the filename is not the same case as the class name; i.e. is the file in the correct directory and correctly named - app/Http/Controllers/Admin/AdminController.php

by_ozturk's avatar

@kokoshneta @tykus

Route :

Route::prefix('admin')->group(function () { Route::match(['get', 'post'], 'login', [AdminController::class, 'login']);

Route::middleware(['admin'])->group(function () {
    Route::get('dashboard', [AdminController::class, 'dashboard']); ...

AdminController :

namespace App\Http\Controllers\Admin;

use App\Models\Admin; use App\Models\Projects; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Models\About; use App\Models\Contact; use App\Models\Services; use App\Models\Settings; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Image;

class AdminController extends Controller {

public function dashboard()
{
  $logo = Settings::all();
  if (!Auth::guard('admin')->check())
  {
      
     return redirect('/admin/login');
  
  
    }    
    return view('admin.dashboard', compact('logo'));
} ....
by_ozturk's avatar

@kokoshneta

It works fine locally, but this is the first time I'm uploading the project to the server. Where exactly should I look?

tykus's avatar
tykus
Best Answer
Level 104

@by_ozturk your local environment might be a case-insensitive operating system; whereas the production environment might be case-sensitive. In such cases, you need to be fastidious with your file, class, variable etc. naming. This is why I asked about the filename for the Controller class

1 like
kokoshneta's avatar

@by_ozturk First of all, how did you deploy the app to the server? Did you just upload the files via FTP? Did you deploy from a repository? Something else?

Secondly, Laravel uses Composer to install, load and locate classes, including your own classes. If Composer isn’t properly set up on your server (e.g., if the composer.lock file isn’t up to date), it won’t be able to find any classes.

Thirdly, even if Composer is working correctly, the actual file that contains the class still needs to be there in the right folder on the server.

by_ozturk's avatar

@kokoshneta

I installed it through DirectAdmin panel, not by FTP. I have a current version of composer and I can use it. I am not exactly sure about the folder path.

by_ozturk's avatar

@kokoshneta I uploaded all the files to the public_html folder and I edited the path for the index.php file.

tominthomas's avatar

@by_ozturk Brother now I'm also facing exactly the same issue. I tried different solution but nothing works for me. How did you resolved this? Can you please explain?

Please or to participate in this conversation.