Skip to content

ServiceProvider interface — opt-in modern plugin contract #1983

@bpamiri

Description

@bpamiri

Summary

Define a wheels.ServiceProviderInterface with register(container) and boot(app) methods. Plugins that implement this interface get the modern lifecycle; others continue with mixin injection. This is the key 3.x bridge to the 4.0 Service Provider model (#1917).

Proposed Interface

// vendor/wheels/ServiceProviderInterface.cfc
interface {
    /**
     * Register services, bindings, and config with the DI container.
     * Called during plugin load phase.
     */
    public void function register(required any container);

    /**
     * Boot the plugin after all providers have registered.
     * Access to routes, middleware, events, and resolved services.
     */
    public void function boot(required any app);
}

Dual-Mode Support

A plugin can include both a ServiceProvider.cfc implementing this interface AND legacy mixin methods during migration:

plugins/myPlugin/
├── MyPlugin.cfc          ← legacy mixin plugin (still works)
├── ServiceProvider.cfc   ← new-style provider (also detected)
└── plugin.json           ← manifest

Detection

During $pluginsProcess():

  1. Check for ServiceProvider.cfc in plugin directory
  2. If found, instantiate and verify it implements the interface
  3. Collect all providers, call register() in load order
  4. After all registered, call boot() in load order

Files

  • New: vendor/wheels/ServiceProviderInterface.cfc
  • Modified: vendor/wheels/Plugins.cfc — detect and invoke service providers

Phase

Phase 3 — Migration Path to Service Providers (3.x → 4.0 bridge)

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