Masonite 2.2
Route Prefixes
Previously you had to append all routes with a /
character. This would look something like:
You can now optionally prefix this without a /
character:
URL parameters can now optionally be retrieved from the controller definition
Previously we had to do something like:
Now we can optionally get the parameter from the method definition:
Learn more in the Controllers documentation here.
Added a storage manager and disk storage drivers
This is used as a wrapper around I/O operations. It will also be a wrapper around the upload drivers and moving files around and other file management type operations
Async driver now can be specified whether to use threading or processing
We can now specify directly in the configuration file whether or not the threading or multiprocessing for the async type operations.
Learn more in the Queues documentation here.
Added new HTTP Verbs
We added 4 new HTTP verbs: HEAD
, CONNECT
, OPTIONS
, TRACE
. You import these and use them like normal:
Learn more in the Routes documentation here.
JSON error responses
If the incoming request is a JSON request, Masonite will now return all errors as JSON
Rearranged Drivers into their own folders
This is more of an internal change for Core itself.
Craft serve command defaults to auto-reloading
Before we had to specify that we wanted the server to auto-reload by specifying a -r flag:
Now we can just specify the serve command it will default to auto-reloading:
You can now specify it to NOT auto-reload by passing in 1 of these 2 commands:
Learn more in the Craft commands documentation here.
Added Accept('*') to drivers
By default you can only upload image files because of security reasons but now you can disable that by doing an accept('*') option:
Learn more in the Uploading documentation here.
Added much more view helpers
Learn more in the Views documentation here.
All Tests are now unittests
We moved from pytest to unittests for test structures.
Learn more in the Testing documentation here.
Added a better way to run database tests
Added a new DatabaseTestcase
so we can properly setup and teardown our database. This works for sqlite databases by default to prevent your actual database from being destroyed.
The back view helper now defaults to the current path
Before in templates we had to specify a path to go back to but most of the time we wanted to go back to the current path.
Instead of:
We can now do:
In order to learn how to use this you can visit the documentation here.
Learn more in the Requests documentation here.
Added a completely new validation library
We built a new validation library from scratch and completely ripped out the old validation code. Any current validation code will need to be updated to the new way.
The new way is MUCH better. You can read about it in the new validation section here.
Learn more in the Validation documentation here.
Auth class does not need the request class.
Previously we needed to pass in the request object to the Auth class like this:
Now we have it a bit cleaner and you can just resolve it and the request class will be injected for you
Completely changed how classes are resolved on the backend
You may not notice anything but now if you bind a class into the container like this:
It will be resolved when you resolve it:
This is why the Auth class no longer needs to accept the request class. Masonite will inject the request class for you when you resolve the class.
This works with all classes and even your custom classes to help manage your application dependencies
Added new register method to the Auth
class.
Auth
class.You can now do something like:
Learn more in the Authentication documentation here.
Changed all regex compiling to be done before the server starts
Previously, each route's regex was being compiled when Masonite checked for it but we realized this was redundant. So now all route compiling is done before the server starts.
This has given Masonite a bit of a speed boost.
Container Remembering
Masonite now has the ability to remember the previous container bindings for each object. This can speed of resolving your code by 10-15x. This is disabled by default as it is still not clear what kind of issues this can cause.
This is scheduled to be set by default in the next major version of Masonite
Learn more in the Service Container documentation here.
Added a new with_errors()
method in order to cut down on setting an errors session.
with_errors()
method in order to cut down on setting an errors session.Now instead of doing this:
we can now shorten down the flashing of errors and do:
Learn more in the Requests documentation here.
Last updated