Improve DI container fallback: specific exception handling and logging#2289
Merged
ArnaudLigny merged 4 commits intophp-difrom Jan 19, 2026
Merged
Improve DI container fallback: specific exception handling and logging#2289ArnaudLigny merged 4 commits intophp-difrom
ArnaudLigny merged 4 commits intophp-difrom
Conversation
Co-authored-by: ArnaudLigny <80580+ArnaudLigny@users.noreply.github.com>
Co-authored-by: ArnaudLigny <80580+ArnaudLigny@users.noreply.github.com>
… namespace prefix Co-authored-by: ArnaudLigny <80580+ArnaudLigny@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Address feedback on PHP-DI integration for dependency injection
Improve DI container fallback: specific exception handling and logging
Jan 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request improves the DI container fallback mechanism in the Builder class by making exception handling more specific and adding observability through logging. The changes ensure that only genuine DI container lookup failures trigger the fallback, while providing visibility when this exceptional path is taken.
Changes:
- Refined exception handling to catch only
DI\NotFoundExceptioninstead of all exceptions - Added warning log when fallback to direct instantiation occurs
- Fixed Parsedown DI configuration to explicitly inject Builder parameter
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Builder.php | Imported NotFoundException, changed exception handling to be more specific, added logging for fallback scenarios, and improved documentation comments |
| config/dependencies.php | Explicitly configured Builder parameter injection for Parsedown class to ensure proper DI container resolution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Changes proposed in this pull request:
The fallback mechanism in
Builder.phpsilently caught all exceptions when resolving steps from the DI container, potentially hiding configuration errors.Exception Handling
DI\NotFoundExceptioninstead of\ExceptionDI\NotFoundExceptionclassObservability
Documentation
DI Configuration Fix
Builderparameter intoParsedownclass configuration💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.