you can do:
from masonite.facades import Mail
To import any built-in facades you can import them from the
from masonite.facades import Request
avatar = Request.input('avatar_url')
Masonite ships with several facades you can use out of the box:
To create your own facade is simple:
from masonite.facades import Facade
key = 'container_key'
Then import and use your facade:
from app.facades import YourFacade
To benefit from code intellisense/type hinting when using Facade (e.g. in VSCode editor) you should create a
.pyifile just next to your facade file class to add type hinting to your new facade.
Then in this facade you should declare your typed methods. Here is a partial example of the Mail facades types hints:
from typing import TYPE_CHECKING
from ..mail import Mailable
"""Handle sending e-mails from Masonite via different drivers."""
def mailable(mailable: "Mailable") -> "Mail":
def send(driver: str = None):
- methods code is not present, but replaced with
- methods do not receive
selfas first argument. Because when calling the facade we don't really instantiate it (even if we get an instance of the object bound to the container). This allow to have the correct type hint behaviour.