Masonite Documentation
v2.3
v2.3
  • Introduction and Installation
  • Creating a Blog
  • Sponsors
  • The Basics
    • Controllers
    • Helper Functions
    • Requests
    • Routing
    • Static Files
    • Views
  • The Craft Command
    • Introduction
    • Creating Commands
  • Architectural Concepts
    • Request Lifecycle
    • Service Container
    • Service Providers
  • Advanced
    • Autoloading
    • Creating a Mail Driver
    • Creating Packages
    • Database Seeding
    • Extending Classes
    • Middleware
    • Responses
    • Sessions
    • Status Codes
    • Validation
  • Useful Features
    • Broadcasting
    • Caching
    • Compiling Assets
    • Environments
    • Events
    • Framework Hooks
    • Mail
    • Queues and Jobs
    • Task Scheduling
    • Testing
    • Selenium Testing
    • Template Caching
    • Uploading
    • View Composers, Sharing and Filters
  • Security
    • Authentication
    • CSRF Protection
    • Encryption
    • Headers
    • Releases
  • Orator ORM
    • Database Migrations
    • Basic Usage
    • Collections
    • ORM
    • Pagination
    • Query Builder
    • Schema Builder
  • Managers and Drivers
    • About Drivers
    • About Managers
    • Contracts
  • Official Packages
    • Masonite API
    • Masonite Billing
    • Masonite Logging
    • Masonite Notifications
  • Masonite Essentials
    • Hash ID's
  • Tutorials
    • Creating a Blog
  • How-to Guides
    • Build Email Verification from Scratch With Masonite Framework and JSON Web Tokens
    • Deploying a Masonite Application to Heroku
    • How To Deploy Masonite to PythonAnywhere
    • How-To: Use RabbitMQ with Masonite 2.0 queues
    • How To Use The Repository Pattern with Masonite
    • Making Masonite and Laravel Mix work together
  • Deployment
    • Drivers
    • Optimization
  • Masonite ORM [In development]
    • White Page
  • Prologue
    • Contributing Guide
    • How To Contribute
    • Release Cycle
    • Known Installation Issues
    • Deprecation
  • What's New
    • Masonite 1.3
    • Masonite 1.4
    • Masonite 1.5
    • Masonite 1.6
    • Masonite 2.0
    • Masonite 2.1
    • Masonite 2.2
    • Masonite 2.3
  • Upgrade Guide
    • Masonite 1.3 to 1.4
    • Masonite 1.4 to 1.5
    • Masonite 1.5 to 1.6
    • Masonite 1.6 to 2.0
    • Masonite 2.0 to 2.1
    • Masonite 2.1 to 2.2
    • Masonite 2.2 to 2.3
Powered by GitBook
On this page
  • Controller Constructors
  • Tinker Command
  • Show Routes Command
  • Server Reloading
  • Autoloading
  • Updated Libraries
  • Removed Importing Duplicate Class Names
  • Redirection Provider
  • Redirection
  • Request Only
  • Get Request Method
  • New Argument in Request.all
  • Made several changes to the CSRF Middleware
  • Added Scheduler to Masonite
  • Added Database Seeding Support
  • Added a New Static File Helper
  • Added a New Password Helper
  • Added Dot Notation To Upload Drivers And Dictionary Support To Driver Locations.
  • Added Status Code Provider
  • Added Explicitly Imported Providers
Edit on Git
Export as PDF
  1. What's New

Masonite 2.0

PreviousMasonite 1.6NextMasonite 2.1

Last updated 6 years ago

Masonite 2 brings an incredible new release to the Masonite family. This release brings a lot of new features to Masonite to include new status codes, database seeding, built in cron scheduling, controller constructor resolving, auto-reloading server, a few new internal ways that Masonite handles things, speed improvements to some code elements and so much more. We think developers will be extremely happy with this release.

Upgrading from Masonite 1.6 to Masonite 2.0 shouldn't take very long. On an average sized project, this upgrade should take around 30 minutes. We'll walk you through the changes you have to make to your current project and explain the reasoning behind it.

Checkout the

Controller Constructors

Controller constructors are now resolved by the container so this removed some redundancy within your code and any duplicated auto resolving can now be directly in your constructor:

from masonite.request import Request

class YourController:
    def __init__(self, request: Request):
        self.request = Request
    
    def show(self):
        print(self.request) # <class masonite.request.Request>

Read more in the documentation.

Tinker Command

There is a new command that starts a Python shell and imports the container for you already. Test it out to verify that objects are loaded into your container correctly. It's a great debugging tool.

$ craft tinker

Show Routes Command

Masonite 2 ships with an awesome little helper command that allows you to see all the routes in your application

$ craft show:routes

Server Reloading

A huge update to Masonite is the new --reload flag on the serve command. Now the server will automatically restart when it detects a file change. You can use the -r flag as a shorthand:

$ craft serve -r

Autoloading

An incredible new feature is autoloading support. You can now list directories in the new AUTOLOAD constant in your config/application.py file and it will automatically load all classes into the container. This is great for loading command and models into the container when the server starts up.

You can also use this class as a standalone class in your own service providers.

Updated Libraries

Updated all libraries to the latest version with the exception of the Pendulum library which latest version is a breaking change and therefore was left out. The breaking change would not be worth it to add the complexity of upgrading so you may upgrade on a per project basis.

Removed Importing Duplicate Class Names

Previously you had to import classes like:

from masonite.drivers.UploadDriver import UploadDriver

Now you can simply specify:

from masonite.drivers import UploadDriver

Because of this change we no longer need the same duplicated class names in the PROVIDERS list either.

Redirection Provider

Removed the need for the redirection provider completely. You need to remove this from your PROVIDERS list.

Redirection

Renamed Request.redirectTo to Request.redirect_to

Also removed the .send() method and moved the dictionary into a parameter:

def show(self):
    return request().redirect('/dashboard/@id', {'id': '5'})

Request Only

Added a new Request.only method to fetch only specific inputs needed.

Get Request Method

Added a new Request.get_request_method() method to the Request class.

New Argument in Request.all

You can now completely remove fetching of any inputs that Masonite handles internally such as __token and __method when fetching any inputs. This is also great for building third party libraries:

Request.all(internal_variables=False)

Made several changes to the CSRF Middleware

Because of the changes to internal framework variables, there are several changes to the CSRF middleware that comes in every application of Masonite.

Added Scheduler to Masonite

Added a new default package to Masonite that allows scheduling recurring tasks:

Added Database Seeding Support

It's important during development that you have the ability to seed your database with dummy data. This will improve team development with Masonite to get everyones database setup accordingly.

Added a New Static File Helper

Now all templates have a new static function in them to improve rendering of static assets

Added a New Password Helper

You can use the password helper to hash passwords more simply than using straight bcrypt:

from masonite.helpers import password

password('secret') # returns bcrypt password

Added Dot Notation To Upload Drivers And Dictionary Support To Driver Locations.

You can now specify which location in your drivers you want to upload to using a new dot notation:

Upload.store(request().input('file'), 'disk.uploads')

This will use the directory stored in:

DRIVERS = {
  'disk': {
    'uploads': 'storage/uploads',
    'profiles': 'storage/static/users/profiles/images'
  },
  ...
}

Added Status Code Provider

Masonite 2 removes the bland error codes such as 404 and 500 errors and replaces them with a cleaner view. This also allows you to add custom error pages.

Added Explicitly Imported Providers

Providers are now explicitly imported at the top of the file and added to your PROVIDERS list which is now located in config/providers.py. This completely removes the need for string providers and boosts the performance of the application sustantially

Read more in documentation.

Read more in documentation.

Read more in Introduction documentation.

Read more in documentation.

Read more about changing duplicated class names under the documentation.

Read more in the documentation.

Read more in documentation.

Read more in documentation.

Read more in documentation.

Be sure to read the changes in the .

Read about Masonite Scheduler under the documentation.

Read more in the documentation.

Read more in the documentation.

Read more in the documentation.

Read more in the documentation.

Read more in the documentation.

Autoloading
Upgrade Guide 1.6 to 2.0
Task Scheduling
Database Seeding
Static Files
Status Codes
Upgrade Guide for Masonite 1.6 to 2.0
Controllers
Requests
Requests
Requests
Requests
Uploading
Encryption
Duplicate Class Names
The Craft Command Introduction
The Craft Command Introduction
The Craft Command