Skip to content

Integrate bind-value filters with lazy provider loading and friendly diagnostics #744

Open

Description

@g105b

Integrate the bind-value filters proposed in phpgt/DomTemplate#491 with WebEngine. DomTemplate should own the filter pipeline and explicit Binder registration API, without depending on WebEngine or its service container.

Add app.bind_filter=BindFilter beneath service_loader in config.default.ini. Resolve the configured provider using the application namespace, following the ServiceLoader naming conventions. Load and register it lazily when a binding first needs a filter, so applications without filtered bindings do not need a provider class. Explicitly registered filters should work without requiring the default provider.

Use one shared filter instance per request for all page, component and list bindings. Supply dependencies explicitly through setDependency(object $dependency). Within a filter method, getDependency(Something::class) returns the supplied dependency, or null when none is available, so the filter can use it optionally. Do not require constructor injection or automatically resolve missing dependencies from the service container. The dependency API belongs to the standalone DomTemplate filter class; WebEngine integrates the shared instance.

Extend ExceptionContextProvider to explain missing providers and unknown filters in development, with suggested fixes and links to the WebEngine wiki. Retain the original exceptions and omit the extra guidance in production.

Cover lazy loading, explicit registration, shared filter instances, optional dependencies and development/production diagnostics with tests. Document the configuration and provider setup in the WebEngine wiki, linking to DomTemplate documentation for the standalone filter API.

Depends on the DomTemplate filter API in phpgt/DomTemplate#491.

Activity

  1. g105b commented on Nov 6, 2026

    @g105b
    MemberAuthor

    The filter design now allows multiple provider classes, rather than one provider class for the whole application. DomTemplate PR phpgt/DomTemplate#549 is being updated accordingly. Each registered provider instance remains shared across page, component and list bindings.

    For WebEngine, register a built-in DefaultBindFilter first, supplying a useful set of filters that applications can use without creating their own class. Optional application providers can then add filters or override individual default filters; later registrations take precedence by filter name, while earlier providers remain available for other names. A chain can use filters from several providers. Dependencies remain explicitly supplied through setDependency() and optionally retrieved through getDependency() on each provider instance.

    An absent optional application filter class should not cause an error when the requested filter is supplied by DefaultBindFilter. Friendly diagnostics should explain filters that remain unresolved after checking the registered providers. The actual built-in filter list and WebEngine integration belong to this issue.

    The comma-separated service-loader configuration groundwork is tracked independently in #745.

  2. g105b commented on Nov 6, 2026

    @g105b
    MemberAuthor

    #745 should be merged before work continues on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions