Creates a new ProvidersManager instance.
Configuration options
Current application environment
Arguments to pass to provider constructors
Registers an array of provider nodes to be processed later. Replaces any previously registered providers.
Array of provider nodes to register
Returns the ProvidersManager instance for method chaining
Changes the environment context for filtering providers. Used when the application environment changes after manager creation.
The new environment to set
Returns the ProvidersManager instance for method chaining
Phase 1: Resolves, instantiates, and calls register() on all providers. Creates provider instances and invokes their register methods to bind services to the IoC container. Sets up tracking for providers with shutdown methods.
Promise that resolves when all providers are registered
Phase 2: Calls boot() method on all registered providers. Boot phase occurs after all providers have registered their services, allowing providers to use services from other providers.
Promise that resolves when all providers are booted
Phase 3: Calls start() method on all providers. Start phase is for launching services like HTTP servers, background workers, etc.
Promise that resolves when all providers are started
Phase 4: Calls ready() method on all providers. Ready phase indicates the application is fully started and ready to serve requests. Clears the providers array after completion as they're no longer needed.
Promise that resolves when all providers are ready
Phase 5: Calls shutdown() method on providers that implement it. Shutdown phase allows providers to perform cleanup during graceful app termination. Only providers with shutdown methods are called.
Whether to shutdown providers in reverse order (recommended for cleanup)
Promise that resolves when all providers are shutdown
ProvidersManager handles the complete lifecycle of service providers in an AdonisJS application. It manages provider registration, booting, starting, readying, and shutdown phases.
Service providers are classes that register services, bind dependencies, and set up application components during different phases of the application lifecycle.
Lifecycle phases:
Example