DEV Community

Arunas Skirius
Arunas Skirius

Posted on

2 1

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)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay