Class 'App\Validator' not found laravel

Class 'App\Validator' not found laravel

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Class 'App\Validator' not found laravel

You are encountering a FatalErrorException because your controller explicitly tries to use a class named App\Validator, which does not exist in Laravel 5.1. The error originates from this line in your AuthController.php:

use App\Validator;
return Validator::make($data, [ ... ]);

While the logic inside the validator() method correctly calls the global Validator facade, the use statement at the top of the file is actively looking for a class definition in the App namespace. Since that class was never created by you or provided by Laravel's core, PHP throws a "Class not found" error immediately when the controller loads.

In modern Laravel versions (5.1 and later), the framework does not provide a base App\Validator class for you to inherit from or instantiate directly in this manner. The validation system is handled by the Illuminate\Support\Facades\Validator facade, which provides a static interface to the underlying validation engine. You do not need to import a specific validator class into your controller unless you are creating a custom validator class (which is a different pattern entirely).

Removing the Non-Existent Import

To resolve this immediately, remove the use App\Validator; line from your AuthController.php. The code will then rely on the global facade, which is the intended usage. Your controller file should look like this:

<?php

namespace App\Http\Controllers\Auth;

use App\User;
// use App\Validator; // Remove this line
use Illuminate\Support\Facades\Validator; // Or simply omit if using the global facade directly
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class AuthController extends Controller
{
    use AuthenticatesAndRegistersUsers, ThrottlesLogins;

    public function __construct()
    {
        $this->middleware('guest', ['except' => 'getLogout']);
    }

    protected function validator(array $data)
    {
        // Validator facade is globally available in Laravel 5.1+
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
        ]);
    }

    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);
    }
}

Understanding the Facade Pattern

It is common for beginners to assume that every functionality provided by a namespace requires an explicit use statement. However, Laravel heavily utilizes the Facade pattern. The Validator, Request, DB, and Auth facades are registered in the application's service container and are globally accessible without needing to import them into your controller files.

By removing the incorrect import, you align your code with how Laravel 5.1 is architected. The validator() method expects a single argument: an array of input data. It returns a validation instance that can be checked against the rules defined in the closure. When validation fails, Laravel automatically redirects back to the form (redirect()->back()) and flashes the error messages to the session using withInput().

Addressing URL Structure and Routing

You mentioned moving your application under the domain QADapps and placing index.php and .htaccess in the root directory. The error you are seeing is strictly related to the missing class, not your URL structure. However, ensure that your .htaccess file is correctly configured to route all requests through index.php. If your application is hosted on a subdirectory like /QADapps, the routes defined in your routes/web.php (or routes.php in 5.1) should match the full path or be prefixed accordingly if you are using named routes.

If you were to define custom validators, you would indeed create a class in the App\Validators namespace and import it. For example:

namespace App\Validators;

use Validator;

class RegistrationValidator extends Validator {
    // Custom logic here
}

But for standard registration logic, sticking to the global Validator facade is the correct approach. Ensure you have cleared your application cache using php artisan clear-compiled (if compiled) or simply restarting your server after making these code changes to ensure PHP picks up the new class structure.

Our network