Starting the REPL
You can start the REPL using therepl command:
Features
The AdonisJS REPL provides several powerful features:- Application Context: Access your application instance, container, and all registered services
- Auto-completion: Tab completion for methods and properties
- Helper Methods: Built-in helpers for common tasks
- Module Access: Import and test modules directly
Accessing Application Services
The REPL automatically makes several services available:Using the REPL for Development
Testing Models and Queries
Testing Services
Debugging Configuration
REPL Commands
The REPL supports special commands:Exit a multi-line expression
Clear the REPL context
Exit the REPL session
Show available commands
Load a JavaScript file into the session
Save the session to a file
Custom REPL Bindings
You can extend the REPL with custom bindings using a service provider:Module Re-exports
The REPL module re-exports all functionality from@adonisjs/repl:
The REPL is built on top of Node.js’s native REPL module with AdonisJS-specific enhancements.
Best Practices
Use for quick testing
Use for quick testing
The REPL is perfect for quickly testing code snippets, queries, or services without writing test files.
Avoid production use
Avoid production use
The REPL is a development tool and should not be used in production environments.
Import modules as needed
Import modules as needed
Use dynamic imports to load modules on-demand rather than loading everything at startup.
See Also
- Ace CLI Overview - Learn about other CLI commands
- Testing - Test utilities for unit and integration tests
- Container - Dependency injection container