- What does symfony/polyfill-php73 do in a Laravel app?
- It is a Symfony MIT-licensed compatibility layer that provides PHP 7.3 functions and the JsonException class on older PHP runtimes. In a Laravel app it is only useful when your code or a package calls array_key_first, array_key_last, hrtime, is_countable, or JsonException while you still support PHP below 7.3. It has no service provider, config, or database requirements.
- How do I install symfony/polyfill-php73 in Laravel?
- Run composer require symfony/polyfill-php73, ideally with a version constraint appropriate for your dependency policy. Composer autoloading makes the functions and class available without registering a Laravel service provider. Test on your lowest supported PHP version, not only your local PHP 8 machine.
- Which PHP versions does symfony/polyfill-php73 support?
- The package is intended for projects running PHP versions lower than 7.3 and provides selected PHP 7.3 APIs there. On PHP 7.3 and later, native implementations take precedence and the polyfill should add negligible overhead. It does not backport PHP 7.3 syntax, so code using newer syntax still fails on older runtimes.
- Do I need symfony/polyfill-php73 on Laravel 10 or Laravel 11?
- Usually no, because Laravel 10 requires PHP 8.1+ and Laravel 11 requires PHP 8.2+, where these APIs are native. The polyfill is framework-agnostic and can still appear transitively, so run composer why symfony/polyfill-php73 before adding or removing it. It adds little value for modern Laravel apps unless a dependency needs it.
- Does symfony/polyfill-php73 make all PHP 7.3 features work on older PHP?
- No. It only polyfills the listed functions and JsonException class; it does not make PHP 7.3 syntax or every language feature available on older PHP. Treat it as a targeted API compatibility layer, not a full PHP 7.3 backport.
- How does JsonException work with symfony/polyfill-php73 on PHP 7.2?
- The polyfill can provide the JsonException class on PHP below 7.3, but native json_decode on those versions may not throw it automatically. If you rely on JSON_THROW_ON_ERROR behavior, verify or add wrapper code that throws JsonException yourself. Do not assume the class alone changes json_decode error handling.
- Is symfony/polyfill-php73 already included in Laravel by default?
- It may already be installed transitively through Symfony components or other Composer packages. Run composer show symfony/polyfill-php73 and composer why symfony/polyfill-php73 to confirm before adding a direct dependency. Laravel does not guarantee this specific polyfill is present in every version.
- Can symfony/polyfill-php73 conflict with my own polyfills or shims?
- It can conflict with custom shims that define the same functions or JsonException without guarding with function_exists or class_exists checks. Audit your codebase and dependencies for existing polyfills before adopting it. Replacing ad hoc shims with the Symfony implementation can reduce duplication when safe.
- Is symfony/polyfill-php73 safe for production and how should I test it?
- It is MIT-licensed, Symfony-backed, and widely used, so it is generally low risk in production when a PHP below 7.3 target actually exists. Test on the lowest PHP runtime in your CI matrix, including array_key_first, array_key_last, is_countable, and JSON error handling. Validate hrtime precision separately if you use it for metrics.
- When and how should I remove symfony/polyfill-php73 from a Laravel project?
- Remove it when your minimum supported PHP version reaches 7.3 or higher and no dependency still needs the polyfill. Run composer remove symfony/polyfill-php73, then rerun your test matrix to confirm native functions and JsonException cover your code. No refactoring should be required if you only used the native-compatible APIs.