Masonite Documentation
v4.0
v4.0
  • Introduction and Installation
  • Prologue
    • Creating A Blog Tutorial
    • Release Cycle
    • Contributing Guide
    • How To Contribute
  • The Basics
    • Routing
    • Controllers
    • Middleware
    • Response
    • Request
    • Static Files
    • Views
    • Environments
    • Configuration
    • Error Handling
  • Features
    • API Development
    • Authentication
    • Authorization
    • Broadcasting
    • Caching
    • Compiling Assets
    • Commands
    • CSRF Protection
    • Events
    • Facades
    • Filesystem and Uploading
    • Hash ID's
    • Helpers
    • Mail
    • Notifications
    • Package Development
    • Queues and Jobs
    • Rate Limiting
    • Sessions
    • Task Scheduling
    • Tinker Shell (REPL)
    • Validation
  • Architecture
    • Service Providers
    • Service Container
  • Security
    • CORS
    • Hashing
  • Masonite ORM
    • To Masonite ORM Docs
  • Testing
    • Getting Started
    • HTTP Tests
    • Database Tests
    • Commands Tests
    • Console Tests
    • Mocking
    • Extending
  • Official Packages
    • Masonite Debugbar
  • How-to Guides
    • Handling AJAX requests with expired authentication
    • 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
  • 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
    • Masonite 3.0
  • 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
    • Masonite 2.3 to 3.0
    • Masonite 3.0 to 4.0
Powered by GitBook
On this page
  • Configuration
  • Auto-loading Models
  • Startup script
Edit on GitHub
Export as PDF
  1. Features

Tinker Shell (REPL)

PreviousTask SchedulingNextValidation

Last updated 3 years ago

Masonite Tinker is a powerful REPL (Read, Evaluate, Print and Loop) environment for the Masonite framework. It's a supercharged Python interactive shell with access to the container, models and helpers.

Tinker allows you to interact with your entire Masonite project on the command line, including models, jobs, events, and more. To enter the Tinker environment, run the tinker command:

python craft tinker

This will open a Python shell with the application container (under the app variable), the application models and some helpers imported for you.

Finally you can get an enhanced experience by using the Tinker IPython shell. is an improved Python shell offering some interesting features:

  • Syntax highlighting

  • Tab completion of python variables and keywords, filenames and function keywords

  • Input history, persistent across sessions

  • Integrated access to the pdb debugger and the Python profiler

  • and much more...

You just need to use -i option and install IPython if not installed yet (pip install IPython):

python craft tinker -i

Configuration

Auto-loading Models

By default your app models are loaded from the location configured in your project Kernel. You can override the directory to load models from with the -d flag. It should be a path relative to your project root. For example you can run the following command if your models are located in a models/ folder located at your project root:

python craft tinker -d models/

Startup script

You can use PYTHONSTARTUP environment variable to add a script that you want to run at the beginning of the shell session.

With IPython you can use this variable or put some Python scripts in ~/.ipython/profile_default/startup/. IPython will run those scripts for you at the beginning of the shell session.

IPython