Problem
Global middleware like PageCacheMiddleware, SessionMiddleware, and LayoutMiddleware are hardcoded in GlobalMiddlewareResolver::DEFAULT_BUILT_INS inside marko/core. This means adding or reordering built-in middleware requires touching the core resolver — packages have no way to self-register their middleware.
Proposed Solution
Add a globalMiddleware key to module.php that accepts class strings or ['class' => ..., 'priority' => N] entries. GlobalMiddlewareResolver collects and sorts all declarations from loaded modules by priority (lower = earlier), deduplicating by source (app > modules > vendor). Built-in declarations are removed from the core and moved to their respective packages.
Alternatives Considered
No response
Package
core
Problem
Global middleware like
PageCacheMiddleware,SessionMiddleware, andLayoutMiddlewareare hardcoded inGlobalMiddlewareResolver::DEFAULT_BUILT_INSinsidemarko/core. This means adding or reordering built-in middleware requires touching the core resolver — packages have no way to self-register their middleware.Proposed Solution
Add a
globalMiddlewarekey tomodule.phpthat accepts class strings or['class' => ..., 'priority' => N]entries.GlobalMiddlewareResolvercollects and sorts all declarations from loaded modules by priority (lower = earlier), deduplicating by source (app > modules > vendor). Built-in declarations are removed from the core and moved to their respective packages.Alternatives Considered
No response
Package
core