Repository navigation
refactor: let the WpRest module run without Laravel's application - #464
Merged
Merged
Conversation
WpRestDiscovery resolves controllers through the discovery's instance pool and hands custom HandlesAttributes attributes the PSR-11 container it was given, instead of app(); the wrapper takes the instance instead of building it with resolve() for its logger. An architecture test keeps the module to attributes, discovery, PSR contracts and WordPress. Fixes a REST controller with a constructor dependency never being built.
This was referenced Oct 12, 2026
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.
First step of extracting
pollora/wp-rest(roadmap, medium term: "dependency injection without Laravel's container"). Nothing moves yet: the module stops reaching for Laravel's application.What changes
WpRestDiscoveryresolves each#[WpRestRoute]controller through the discovery's instance pool: Laravel's container in a Pollora application,pollora/discovery's reflection autowiring elsewhere.WpRestAttributableWrappertakes that instance instead of building it (newInstance()with no argument, andresolve(LoggerInterface)on failure).HandlesAttributesattributes get the PSR-11 container given toWpRestDiscovery(autowired by Laravel) instead ofapp().tests/Unit/WpRest/PackageBoundaryTest.php: the module (withPollora\Support\WpGlobals, used by it alone) may only use the attributes, discovery, PSR contracts and WordPress; its service provider stays in the framework.Bug fixed on the way
A controller with a required constructor dependency was never built (
newInstance()failed, the error was logged), so every request to its routes failed withTrying to invoke non static method … without an object. New test: a controller depending on a repository registers its route onrest_api_initand answers through it.Checks
1882 tests, PHPStan 0. pollora-test cannot run the release branch (it lacks
pollora/discoveryandpollora/attributes) and the diff does not apply to develop; the E2E suite covers REST routes with and without permissions.