feat(core): allow packages to declare global middleware in module.php#80
Open
michalbiarda wants to merge 3 commits into
Open
feat(core): allow packages to declare global middleware in module.php#80michalbiarda wants to merge 3 commits into
michalbiarda wants to merge 3 commits into
Conversation
Packages can now declare global HTTP middleware in module.php via the `globalMiddleware` key (flat class-strings or array with class+priority). GlobalMiddlewareResolver merges module entries with built-in defaults, sorts by priority (ascending), and deduplicates using source priority (app > modules > vendor). Built-in GLOBAL_MIDDLEWARE entries retain silent-skip behavior for backwards compatibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PageCacheMiddleware (priority 10), SessionMiddleware (priority 20), and LayoutMiddleware (priority 30) are now declared via globalMiddleware in their respective module.php files instead of being hardcoded in GlobalMiddlewareResolver::DEFAULT_BUILT_INS. The DEFAULT_BUILT_INS constant and builtIns parameter are removed from GlobalMiddlewareResolver — the resolver now only works with module declarations. Package-level tests verify each middleware's priority. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…iscovery withPathAndSource() was silently dropping the globalMiddleware field, causing all module-declared global middleware to never be registered. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
globalMiddlewarekey tomodule.php— accepts class strings or['class' => ..., 'priority' => N]entriesGlobalMiddlewareResolvernow collects, deduplicates (app > modules > vendor), and sorts by priority from module declarations onlyDEFAULT_BUILT_INSconstant andbuiltInsparameter — built-in middleware moved to their packagesPageCacheMiddleware(priority 10),SessionMiddleware(priority 20),LayoutMiddleware(priority 30) now self-register in theirmodule.phpPackageStructureTestfiles verify each middleware declaration and priorityTest plan
composer testpasses (excluding pre-existingDevDownCommandTestflake)packages/core/tests/Unit/Module/GlobalMiddlewareResolverTest.php— all 14 resolver requirements coveredpackages/session/tests/PackageStructureTest.php— SessionMiddleware at priority 20packages/page-cache/tests/PackageStructureTest.php— PageCacheMiddleware at priority 10packages/layout/tests/PackageStructureTest.php— LayoutMiddleware at priority 30Closes #79
🤖 Generated with Claude Code