Skip to content

Use Respect\Config instead of php-di#1666

Closed
alganet wants to merge 1 commit into
Respect:mainfrom
alganet:respect-config
Closed

Use Respect\Config instead of php-di#1666
alganet wants to merge 1 commit into
Respect:mainfrom
alganet:respect-config

Conversation

@alganet

@alganet alganet commented Feb 1, 2026

Copy link
Copy Markdown
Member

Replaces the php-di implementation with Respect\Config, keeps PSR-11 compatibility.

Respect\Config is much lighter (20Kb package, php-di is 80kb), and also much faster (80% gain on cold ValidatorBuild::init) than uncompiled php-di.

While compiled php-di containers would be in theory even faster, it is awkward to commit their artifacts.

Users that want ultimate performance can still leverage php-di with compilation by doing it (together with their app DI defs) and doing setContainer on our ContainerRegistry.


⚠️ This change is experimental ⚠️ Respect\Config 3.0 is not launched yet.

Benchmarks:

image

@codecov

codecov Bot commented Feb 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.58%. Comparing base (699f060) to head (4735dc8).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1666      +/-   ##
============================================
+ Coverage     99.53%   99.58%   +0.04%     
- Complexity      920      922       +2     
============================================
  Files           190      190              
  Lines          2147     2152       +5     
============================================
+ Hits           2137     2143       +6     
+ Misses           10        9       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replaces the php-di implementation with Respect\Config, keeps
PSR-11 compatibility.

Respect\Config is much lighter (20Kb package, php-di is 80kb),
and also much faster (80% gain on cold ValidatorBuild::init)
than uncompiled php-di.

While compiled php-di containers would be in theory even faster,
it is awkward to commit their artifacts.

Users that want ultimate performance can still leverage php-di
with compilation by doing it (together with their app DI defs)
and doing `setContainer` on our `ContainerRegistry`.
@alganet

alganet commented Feb 1, 2026

Copy link
Copy Markdown
Member Author

I know this change would make some plans (autowiring sokil) harder. However, autowire is not PSR-11, and it would imply a soft dependency on php-di (or any other autowiring-enabled framework).

Since version 6, php-di has been adding bloated features that dramatically reduce its runtime performance, and instead they've been focusing on compilation instead.

While compilation is great (I used it in my swoole-microfw experiment), as a library it is awkward for us to deliver compiled containers. That kind of workflow works best when the user compiles the container for his/her own application instead (their stuff + our stuff all compiled together).

Respect\Config is much leaner and has outstanding runtime performance, with still more gains to squeeze (it's basically a PHP 5.3 codebase ported to PHP 8.5 recently). My plan is to keep this as a draft until I launch Config 3.0.

@alganet

alganet commented Feb 1, 2026

Copy link
Copy Markdown
Member Author

I will close and archive this experiment for further reference.

@alganet alganet closed this Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant