Skip to content

Plugin lifecycle hooks: onPluginLoad, onPluginActivate #1979

@bpamiri

Description

@bpamiri

Summary

Plugins currently have no lifecycle hooks beyond init(). They can't run logic on load, register routes, add event listeners, or perform cross-plugin setup. This issue adds two optional lifecycle methods.

Proposed Hooks

onPluginLoad(app)

  • Called after plugin instantiation, before mixin processing
  • Receives an app context struct with access to: route mapper, event system, config
  • Use cases: register routes, add event listeners, declare config requirements

onPluginActivate()

  • Called after all plugins are loaded and all mixins injected
  • Use cases: cross-plugin setup, verify peer dependencies are active, warm caches

Contract

Both methods are optional. Existing plugins without them continue to work unchanged. This is the incremental stepping stone toward the register(container) / boot(app) Service Provider pattern in 4.0 (#1917).

Implementation

  • After CreateObject + init() in $pluginsProcess(), check for and call onPluginLoad(app)
  • After $initializeMixins() completes for all plugins, loop and call onPluginActivate()

Files

  • vendor/wheels/Plugins.cfc:146-178 — extend $pluginsProcess()
  • vendor/wheels/events/onapplicationstart.cfc:235-246 — add post-load activation loop

Phase

Phase 2 — DI Integration & Lifecycle (3.x, backward compatible)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions