config/application.pyfile which contains a list of directories:
appdirectory which unsurprisingly contains all of the application models.
app/modelsit will convert that to
app.modelsand fetch that module. It will use inspection to go through the entire module and extract all classes imported or defined.
Modelclass and the
Userclass. The autoloader will then check if the module of the classes fetched are actually apart of the module being autoloaded.
apprespectively. Remember that we are just autoloaded the
appmodule so it will only bind the
app.Userclass to the container with a binding of the class name:
Userand the actual object itself:
Usermodel is in that directory, the
Usermodel will be loaded into the container when the server starts.
Usermodel will be accessed like:
appdirectory. Feel free to move them anywhere but they will not be autoloaded outside the app directory by default. In order to autoload other directories we can add them to the
AUTOLOADvariable like so:
Requestkey has already been bound into the container (by Masonite itself). Masonite will then detect if that
Requestobject in the container is within the search path. In other words it will check for a
Requestclass inside the current module you are autoloading.
Requestkey in the container is the <class masonite.request.Request> class which is outside of the
appmodule (and inside the
__table__attribute to connect the model to the specific table.
app/modelsdirectory that are instances of the
classesattribute contains a dictionary of all the classes it found.