DEV Community

Arunas Skirius
Arunas Skirius

Posted on

How to use Laravel Facades safely

It's not exactly clear in the Laravel documentation, but there's one thing the Facades do that might introduce accidental bugs in your system:

Facades are like singletons.

Unlike traditional service container bindings with anonymous functions, Facades retain the resolved instance and use that in future Facade calls.

In this article I explain why this is happening, and offer a couple solutions to prevent this bug in your code.

Let me know what you think!

Top comments (0)