Facades provide a static interface to classes bound in the service container, such as Cache::get() or Route::get(). Behind the scenes they resolve the underlying object from the container, making them testable despite the static syntax. Laravel also supports facade mocking (Cache::shouldReceive()) for unit tests.
← Laravel theorytheory 0/50 · 0%
Architecture · easy
18. Facades
Static-like access to container services.
Check your understanding
1. What do facades actually do under the hood?
2. How can you mock a facade in a test?