Repository navigation
Skip env resolution in Config::isEnabled() when no override is set - #131
Merged
rcalicdan merged 1 commit intoNov 11, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Every runtime check calls Config::isEnabled(), which resolved TYPEPHP_DISABLE and TYPEPHP_ENABLED through getEnvValue() and trimmed and filtered them on each call, even when neither is set. Probe for the overrides first and only resolve them when one is present. The probes still run on every call, so values that Dotenv or putenv() set after boot keep taking effect. PHP 8.4, 2M iterations, best of 5: Config::isEnabled() 192 ns -> 139 ns call with @param/@return contract 3155 ns -> 2986 ns
naxvog
force-pushed
the
perf/config-is-enabled-fast-path
branch
from
November 11, 2026 08:35
65cd450 to
296a002
Compare
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.
Problem
Every runtime check calls
Config::isEnabled(). On each call it resolvedTYPEPHP_DISABLEandTYPEPHP_ENABLEDthroughgetEnvValue()and then trimmed and filtered the results, even when neither override is set, which is the normal case.Change
Probe for the overrides first (
$_ENV,$_SERVER,getenv(),defined()), and run the existing resolution only when one is present.The probes still run on every call. Values that Dotenv or
putenv()set after boot keep taking effect, which the existing "Laravel Dotenv compatibility" tests cover. Caching the result was not an option for that reason.Measurements
PHP 8.4, no opcache, 2M iterations, best of 5, three interleaved runs:
Config::isEnabled()@param positive-intand@return positive-int@param list<int>(20 items)That is about 5% and 3% per instrumented call. The remaining cost is the two
getenv()calls, which cannot be dropped without changing behaviour.Verification
putenv()path of both variables intests/Internal/Util/ConfigTest.php. The existing$_ENVand$_SERVERtests pass unchanged.