Facades
Facades are an easy way to access the container classes without making them from the container

Built in Facades

Masonite ships with several facades you can use out of the box.
Facades are just a shortcut to a key in the IOC container.
To import a facade you can import them from the masonite.facades namespace:
1
from masonite.facades import Request
2
3
def show(self):
4
avatar = Request.input('avatar_url')
Copied!
The available facades are:
  • Request
  • Response
  • View
  • Mail
  • Hash
  • Session
  • Notification
  • Auth
  • Config
  • Url

Creating Your Own Facades

To create your own facade is simple:
1
from masonite.facades import Facade
2
3
class YourFacade(metaclass=Facade):
4
key = 'container_key'
Copied!
Then import and use your facade:
1
from app.facades import YourFacade
2
3
YourFacade.method()
Copied!
Last modified 3mo ago
Export as PDF
Copy link