Skip to content

PluginRegistrar

The fluent contribution API handed to PluginInterface::register().

Every method routes to a seam that already exists in the framework — this class adds no new low-level mechanism, it just gives plugins one coherent, discoverable surface for the contribution kinds core itself knows about. A plugin package that owns its own registry (e.g. MCP’s McpCatalog) is registered by calling that registry directly from PluginInterface::register() instead of gaining a bespoke method here — this class must not grow a method per plugin package, or every package would force a core release to gain a contribution seam. Contributions to static seams (config, middleware, events) are applied immediately; contributions that need a per-Context object (DI services, named HTTP clients) are recorded on PluginManager and applied when that object is built. Route/command contributions are recorded and consulted by the route scanner / console.

Override rules: config defaults and container services are set-if-absent, so app settings/bindings (loaded before plugins) always win, and among plugins the first to contribute a given key/id wins.

final class PluginRegistrar

SourcePlugin/PluginRegistrar.php

public function __construct(string $pluginName): mixed

ParameterTypeDescription
$pluginNamestring

Returns mixed

MethodDescription
attributedMiddleware(string $fqcn, ?callable(\Quiote\Context): \Psr\Http\Server\MiddlewareInterface $factory = null): PluginRegistrarAdd an app/plugin middleware class to #[Middleware] attribute scanning — ordering comes from the class’s own attribute.
command(string $fqcn): PluginRegistrarContribute a console command class (see PluginManager::contributedCommands()).
configDefault(string $key, mixed $value): PluginRegistrarA config default (set-if-absent: app settings.* and earlier plugins win).
databaseDriver(string $alias, class-string<Database> $adapterClass): PluginRegistrarRegister a database driver alias, so databases.xml can reference the adapter by a short name (class="eloquent") instead of a fully-qualified class name.
developerExceptionRenderer(callable(): \Quiote\Exception\Rendering\ExceptionRenderer $factory): PluginRegistrarRegister the “developer” exception renderer used by ErrorHandlingMiddleware when core.developer_exceptions is true.
httpClient(string $name, callable $configurator): PluginRegistrarConfigure a named HTTP client (applied to the container’s HttpClientFactory).
listen(string $eventClass, callable $listener, int $priority = 0): PluginRegistrarRegister an event listener (routes to Events::listen()).
middleware(string $fqcn, callable $factory, ?string $after = null, ?string $before = null, int $priority = 0): PluginRegistrarInsert a middleware at a position (routes to MiddlewareCatalog::register()).
moduleDirectory(string $dir): PluginRegistrarContribute a module directory.
pluginName(): stringReturns the name of the plugin whose contributions this registrar records.
safeExceptionRenderer(callable(): \Quiote\Exception\Rendering\ExceptionRenderer $factory): PluginRegistrarRegister the “safe” exception renderer used by ErrorHandlingMiddleware when core.developer_exceptions is false (the default, i.e.
service(string $id, mixed $concrete, ?string $scope = null, string ...$aliases): PluginRegistrarA DI service default, applied to each context’s container when built, and only if that id isn’t already bound (app/core win; first plugin wins).
stateReset(string $label, \Closure(): void $reset): PluginRegistrarContribute a callback that clears a plugin-owned static registry, invoked by PluginManager::reset().

public function attributedMiddleware(string $fqcn, ?callable(\Quiote\Context): \Psr\Http\Server\MiddlewareInterface $factory = null): PluginRegistrar

Add an app/plugin middleware class to #[Middleware] attribute scanning — ordering comes from the class’s own attribute.

ParameterTypeDescription
$fqcnstring
$factory?``callable(\Quiote\Context): \Psr\Http\Server\MiddlewareInterface

Returns PluginRegistrar

public function command(string $fqcn): PluginRegistrar

Contribute a console command class (see PluginManager::contributedCommands()).

ParameterTypeDescription
$fqcnstring

Returns PluginRegistrar

public function configDefault(string $key, mixed $value): PluginRegistrar

A config default (set-if-absent: app settings.* and earlier plugins win).

ParameterTypeDescription
$keystring
$valuemixed

Returns PluginRegistrar

public function databaseDriver(string $alias, class-string<Database> $adapterClass): PluginRegistrar

Register a database driver alias, so databases.xml can reference the adapter by a short name (class="eloquent") instead of a fully-qualified class name.

ParameterTypeDescription
$aliasstring
$adapterClassclass-string``<Database>

Returns PluginRegistrar

public function developerExceptionRenderer(callable(): \Quiote\Exception\Rendering\ExceptionRenderer $factory): PluginRegistrar

Register the “developer” exception renderer used by ErrorHandlingMiddleware when core.developer_exceptions is true.

ParameterTypeDescription
$factorycallable(): \Quiote\Exception\Rendering\ExceptionRenderer

Returns PluginRegistrar

public function httpClient(string $name, callable $configurator): PluginRegistrar

Configure a named HTTP client (applied to the container’s HttpClientFactory).

Same signature as HttpClientFactory::configure().

ParameterTypeDescription
$namestring
$configuratorcallable

Returns PluginRegistrar

public function listen(string $eventClass, callable $listener, int $priority = 0): PluginRegistrar

Register an event listener (routes to Events::listen()).

ParameterTypeDescription
$eventClassstring
$listenercallable
$priorityint

Returns PluginRegistrar

public function middleware(string $fqcn, callable $factory, ?string $after = null, ?string $before = null, int $priority = 0): PluginRegistrar

Insert a middleware at a position (routes to MiddlewareCatalog::register()).

$factory is called with the building pipeline’s Context as its argument (ignore it if unneeded — e.g. a single-context feature like MCP captures a fixed context name instead; see Quiote\Mcp\McpPlugin).

ParameterTypeDescription
$fqcnstring
$factorycallable
$after?``string
$before?``string
$priorityint

Returns PluginRegistrar

public function moduleDirectory(string $dir): PluginRegistrar

Contribute a module directory.

Its #[Route] action classes are then discovered by the attribute route scanner alongside the app’s own modules.

ParameterTypeDescription
$dirstring

Returns PluginRegistrar

public function pluginName(): string

Returns the name of the plugin whose contributions this registrar records.

Returns string

public function safeExceptionRenderer(callable(): \Quiote\Exception\Rendering\ExceptionRenderer $factory): PluginRegistrar

Register the “safe” exception renderer used by ErrorHandlingMiddleware when core.developer_exceptions is false (the default, i.e.

ParameterTypeDescription
$factorycallable(): \Quiote\Exception\Rendering\ExceptionRenderer

Returns PluginRegistrar

public function service(string $id, mixed $concrete, ?string $scope = null, string ...$aliases): PluginRegistrar

A DI service default, applied to each context’s container when built, and only if that id isn’t already bound (app/core win; first plugin wins).

$concrete is anything Container::set() accepts (instance, class-string, or factory closure). Extra $aliases are bound to $id if not already present.

ParameterTypeDescription
$idstring
$concretemixed
$scope?``string
$aliasesstring

Returns PluginRegistrar

public function stateReset(string $label, \Closure(): void $reset): PluginRegistrar

Contribute a callback that clears a plugin-owned static registry, invoked by PluginManager::reset().

ParameterTypeDescription
$labelstring
$reset\Closure(): void

Returns PluginRegistrar