Repository navigation
Fix route caching and hydration errors; clean up - #3
Merged
Merged
Conversation
Route defaults now hold only serializable data: an endpoint key and, when every provider is a class string or a Skir::controller()/Skir::method() definition, the provider list itself. The endpoint's SkirServer lives in a container-held registry and is rebuilt lazily from the cached provider list. Provider instances keep working uncached and fail with an explicit error when restored from a route cache instead of a fatal __set_state() call.
Laravel's exception handler already calls render(), so the controller uses the same method instead of a parallel toResponse(). Provider names in invalidRouteProvider() now come from get_debug_type().
ValidationExceptions thrown while hydrating a direct DTO parameter (Laravel Data alwaysValidate(), Simple Data Objects validate()) become skir_validation_failed instead of Laravel's 422 body or a redirect. A payload that cannot be passed to a Form Request or hydrated into the parameter type is now skir_invalid_request (422) instead of a 500. ValidationExceptions thrown by controller code still pass through.
controller_namespace already trims them; request_namespace now does too.
It was byte-identical to skir-controller.stub.
No generator emits it; controllers and handlers receive SkirContext.
Requests always go through RegisteredProcedure::prepare(), so its invoke() shortcut is gone. addMethod() now accepts a PreparesProcedure directly, so ControllerProcedureInvoker no longer needs an __invoke() just to look callable.
ControllerScaffoldingResult::$routeHints duplicated the registrations, RenderedController's className/methods/originalSource were never read, and cleanupFailedAfterControllerPublication() had no callers.
Scaffolded controllers must run on the host PHP, which is what the other parsers in the scaffolder already target.
Explain routes/api.php versus CSRF in routes/web.php, which registrations survive route:cache, that provider-less endpoints share one server, and when DTO hydration returns skir_validation_failed or skir_invalid_request. The manual addMethod() example now runs from a service provider, and the GET example uses the standard query-string form.
Give the AccountController example the constructor its body relies on, and mention routes/api.php, route caching, and DTO hydration error codes.
Add requirements, shorten Why Skir, link the other generator paths, explain how skir:make finds the generator manifest, label the controller example as implemented code, and register the endpoint in routes/api.php with a note on CSRF and route caching.
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.
Follow-ups from a code review. Stacked on #2.
Fixes
route:cachebroke the app. Route defaults held aSkirServerobject, which fatals on load (SkirServer::__set_state()). Route defaults now keep only an endpoint key and, when every provider can be cached, the provider list. A container-heldSkirEndpointRegistrybuilds each endpoint's server lazily after caching. Class strings,Skir::controller()andSkir::method()survive caching. Endpoints that use provider instances throw a clearLogicExceptionon first call when cached.SkirRouteCachingTestcovers the round-trip.ValidationExceptionfrom Laravel Data / Simple Data Objects hydration now returnsskir_validation_failed; before, it gave Laravel's 422 body, or a 302 without an Accept header. ATypeErrorduring hydration, or a non-array payload for a Form Request, returns 422skir_invalid_requestinstead of 500. Business-logicValidationExceptions still pass through.request_namespaceaccepts surrounding backslashes, likecontroller_namespace.Cleanup
RequestContext(type-hintSkirContext),SkirServerException::toResponse()(render()remains),RegisteredProcedure::invoke(),ControllerProcedureInvoker::__invoke(), dead scaffolding members, and a duplicate controller stub.addMethod()also accepts aPreparesProcedure.elseifchains.docs/superpowers, remove unreferenced artwork,.gitattributesexport-ignore (resources/boostandstubsstill ship), fix AGENTS.md.Docs
routes/api.php;routes/web.phpPOSTs get 419 from CSRF.addMethod()belongs in a provider'sboot().skir_validation_failedvsskir_invalid_requestis returned.skir:make, tighter quick start and intro.Breaking:
RequestContext,toResponse(),$route->defaults['skirServer'](useSkirEndpointRegistry::server($route)), and theRenderedControllerconstructor shape.Not done (needs a decision): the reviewer suggested replacing the hand-rolled file-transaction layer in scaffolding (
ControllerScaffolder,ScaffoldingFilesystem,AtomicFilePublisher, about 1,000 lines) with plain writes after validation. The generator error message inskir:makestays hidden on purpose; a test guards against leaking secrets in it.