Matt Stauffer continues his series covering features in the 5.4 version of the Laravel framework with this look at real-time facades, a feature that allows you to use facades on classes without having to pre-define them as before.
Laravel 5.4 introduced a new feature called “real-time facades”, which provide the convenience of facades, defined real-time instead of in classes. Taylor tweeted about it, but I wanted to explain what they are and how they work.
[...] If you’re not familiar with facades in Laravel, they’re shortcut classes that provide static access to non-static methods on service classes bound to Laravel’s container. [...] Real-time facades let you create your own facades on the fly. Instead of having to create a facade class like the Session facade class I referenced above, you can use a class as its own facade by adding Facades to the beginning of its own namespace.
He includes code showing how facades are used and what kind of functionality they offer. He then covers the switch to the real-time version, switching up the namespace to tell the framework to perform the new logic. He ends the post with examples of this functionality in use inside of a view, class or any other library in your application.