Laravel Facades

Print Print
Reading time 1:7

Facades are a feature of the Laravel framework that provide a static-style interface to classes registered in the application's service container. They allow expressive, memorable syntax while still keeping the underlying object testable and configurable, since a facade is really just resolving an object from the container at runtime.

Using a Facade

Example usage

use Illuminate\Support\Facades\Cache;

Cache::put('key', 'value', 600);
$value = Cache::get('key');

Although Cache::put() looks like a static method call, it is actually being called on an underlying object resolved dynamically from the service container.

How Facades Work

Every facade class extends Laravel's base Facade class and defines a getFacadeAccessor method returning the name of the service it represents. PHP's __callStatic magic method intercepts static calls and forwards them to the resolved instance.

Facades vs Dependency Injection

Facades and constructor-based dependency injection can generally be used interchangeably, since both resolve the same underlying class from the container. Facades favor brevity and readability, while dependency injection makes a class's dependencies explicit in its constructor signature.

Real-Time Facades

Laravel also supports "real-time facades," which let any class in the application be used as if it were a facade by prefixing its namespace with Facades\ at the point of use, without needing to create a dedicated facade class.

By: Tomas Silny
Edited: 2026-08-13 03:31:19