What is a Facade in Laravel?

A facade acts like a shortcut or a “helper” that provides a simple and easy way to access that class.

Simplified Explanation:

Imagine you have a class (let’s call it the “real class”) that contains all the business logic or heavy work.

Now, instead of directly using that class, you have a facade that provides you an easy, simplified, and often static interface to interact with that class. This makes things more readable and concise.

Facade vs Class

  • A class is the real object that holds your business logic and methods.
  • A facade acts like a shortcut or a “helper” that provides a simple and easy way to access that class.

Analogy (Simplified):

Imagine you’re at a hotel and want to order room service:

  • Room service (facade): You call the front desk, and they send food to your room. You don’t need to know how the kitchen or delivery works, just that it arrives.
  • The Kitchen (actual class): This is where the food is prepared. You don’t interact with it directly; instead, you use the room service (facade) to make your request.

So, the facade hides the complexity of the class and provides you a clean, easy-to-use interface.

In Laravel:

When you use something like:

Config::get('app.name');

Or:

config('app.name');

The Config facade is not the real class but a “static proxy” to the actual underlying class that handles configuration. It makes it easier to access configuration values without having to instantiate the real Config class manually.

Check the config/app.php File

In your Laravel app, you can also check the config/app.php file, which contains a list of facades and service providers that are automatically registered. Look for the aliases array:

'aliases' => [
    'App'           => Illuminate\Support\Facades\App::class,
    'Artisan'       => Illuminate\Support\Facades\Artisan::class,
    'Auth'          => Illuminate\Support\Facades\Auth::class,
    'Cache'         => Illuminate\Support\Facades\Cache::class,
    'Config'        => Illuminate\Support\Facades\Config::class,
    'DB'            => Illuminate\Support\Facades\DB::class,
    'Log'           => Illuminate\Support\Facades\Log::class,
    'Mail'          => Illuminate\Support\Facades\Mail::class,
    'Queue'         => Illuminate\Support\Facades\Queue::class,
    'Route'         => Illuminate\Support\Facades\Route::class,
    'Session'       => Illuminate\Support\Facades\Session::class,
    'Storage'       => Illuminate\Support\Facades\Storage::class,
    'URL'           => Illuminate\Support\Facades\URL::class,
    'Validator'     => Illuminate\Support\Facades\Validator::class,
    'View'          => Illuminate\Support\Facades\View::class,
    // More facades here...
],
AliasUnderlying Facade ClassPurpose
AppIlluminate\Support\Facades\AppAccess the application container
ArtisanIlluminate\Support\Facades\ArtisanRun Artisan commands
AuthIlluminate\Support\Facades\AuthAuthentication services
CacheIlluminate\Support\Facades\CacheCaching system
ConfigIlluminate\Support\Facades\ConfigApp configuration
DBIlluminate\Support\Facades\DBDatabase queries
LogIlluminate\Support\Facades\LogLogging
MailIlluminate\Support\Facades\MailSending emails
QueueIlluminate\Support\Facades\QueueJob queue handling
RouteIlluminate\Support\Facades\RouteDefine and manage routes
SessionIlluminate\Support\Facades\SessionSession handling
StorageIlluminate\Support\Facades\StorageFilesystem (local, S3, etc.)
URLIlluminate\Support\Facades\URLURL generation
ValidatorIlluminate\Support\Facades\ValidatorValidation
ViewIlluminate\Support\Facades\ViewView rendering

Now dont confused between class & facade. Facade uses Laravel’s service container always & Defined in config/app.php aliases always.

So In Laravel, a facade is a shortcut that provides a simple, static-like way to access services from the service container (like Cache, DB, or Auth). These are defined in the aliases array in config/app.php.
On the other hand, when you write class User extends Model, you’re creating a regular Eloquent model, not a facade. Although it uses static methods like User::find(), it’s part of Laravel’s ORM system and doesn’t go through the service container like facades do. So, User is not a facade — it’s just a model.