Application class is the core of an AdonisJS application. It manages the application lifecycle, service providers, container bindings, and configuration. This module re-exports all functionality from @adonisjs/application.
Import
ApplicationService Interface
TheApplicationService is a type-safe interface that extends the Application class with all registered container bindings.
Key Properties
environment
The current environment in which the application is running.Returns the current application environment.
appRoot
The root URL of the application.Returns the application root as a URL object.
container
The IoC container instance for dependency injection and service resolution.Returns the container instance with all registered bindings.
config
The configuration store containing all application configuration.Returns the configuration provider instance.
isReady
Indicates whether the application has been fully started.Returns
true if the application has completed the start phase.isBooted
Indicates whether the application has been booted.Returns
true if the application has completed the boot phase.Lifecycle Methods
init
Initializes the application by loading service providers and registering bindings.Returns a promise that resolves when initialization is complete.
boot
Boots all registered service providers.Returns a promise that resolves when all providers have been booted.
start
Starts the application and triggers the ready hook of all providers.Callback function to execute during the start phase, after booting but before the ready hook.
Returns a promise that resolves when the application is fully started.
terminate
Terminates the application gracefully by running all termination hooks.Returns a promise that resolves when the application has been terminated.
Lifecycle Hooks
booting
Register a callback to be executed during the booting phase.Callback function to execute during booting.
booted
Register a callback to be executed after the application has booted.Callback function to execute after booting.
starting
Register a callback to be executed during the starting phase.Callback function to execute during starting.
ready
Register a callback to be executed when the application is fully ready.Callback function to execute when ready.
terminating
Register a callback to be executed during termination.Callback function to execute during termination.
Environment Management
setEnvironment
Sets the application environment.The environment to set. Valid values:
'web', 'console', 'test', 'repl'.inProduction
Check if the application is running in production mode.Returns
true if NODE_ENV is set to 'production'.inDev
Check if the application is running in development mode.Returns
true if NODE_ENV is not set to 'production' or 'test'.inTest
Check if the application is running in test mode.Returns
true if NODE_ENV is set to 'test'.Notification
notify
Notifies the parent process with application status information.Notification payload to send to the parent process.