AdonisJS API
    Preparing search index...

    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:

    1. Register: Bind services to the IoC container
    2. Boot: Initialize services after all providers are registered
    3. Start: Start services (e.g., HTTP server, background jobs)
    4. Ready: Notify services that application is ready to serve requests
    5. Shutdown: Gracefully shutdown services during app termination
    const manager = new ProvidersManager({ environment: 'web', providersState: [app] })
    manager.use([
    { file: () => import('./providers/app_provider'), environment: ['web', 'console'] }
    ])
    await manager.register()
    await manager.boot()
    await manager.start()
    await manager.ready()
    Index
    • Registers an array of provider nodes to be processed later. Replaces any previously registered providers.

      Parameters

      Returns this

      Returns the ProvidersManager instance for method chaining

    • Changes the environment context for filtering providers. Used when the application environment changes after manager creation.

      Parameters

      Returns this

      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.

      Returns Promise<void>

      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.

      Returns Promise<void>

      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.

      Returns Promise<void>

      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.

      Returns Promise<void>

      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.

      Parameters

      • inReverseOrder: boolean

        Whether to shutdown providers in reverse order (recommended for cleanup)

      Returns Promise<void>

      Promise that resolves when all providers are shutdown