- What is symfony/polyfill-php82 used for?
- It is a Symfony runtime polyfill that defines selected PHP 8.2 classes, interfaces, and functions on older PHP versions. It covers items such as AllowDynamicProperties, SensitiveParameter, Random engine interfaces, ODBC connection-string helpers, and ini_parse_quantity. It is meant for compatibility, not for adding new PHP syntax. In Laravel it usually arrives as a transitive Composer dependency.
- Is symfony/polyfill-php82 compatible with Laravel?
- Yes. It has no service provider, config file, publish step, or bootstrap hook, so it does not change Laravel's architecture. It relies on Composer autoloading and Laravel's existing Symfony components. It does not conflict with laravel/framework or common packages under normal Composer constraints.
- Do I need to install symfony/polyfill-php82 in my Laravel app?
- Usually you do not require it directly unless you are targeting PHP below 8.2 and need one of its polyfilled features. It often appears transitively through Symfony packages. If Composer already resolves it, you can leave it alone. Add it explicitly only when your own code depends on the provided classes or functions on older PHP.
- How do I install symfony/polyfill-php82?
- Run composer require symfony/polyfill-php82:^1.43 in the Laravel project. There is no provider registration, no config publishing, and no migration step. After installing, flush Composer autoload and run your test suite. For production, deploy with composer install --no-dev --optimize-autoloader.
- Does symfony/polyfill-php82 let me use PHP 8.2 syntax like readonly classes or enums on PHP 8.1?
- No. It is a runtime polyfill for selected classes, interfaces, and functions, not a syntax transformer. PHP 8.2 syntax such as readonly classes, standalone true, false, and null types, enums, and DNF types will still fail to parse on older PHP. You still need a syntax audit or static analysis with a pinned PHP version before adopting those features.
- Which PHP 8.2 features does symfony/polyfill-php82 provide?
- The package provides AllowDynamicProperties, SensitiveParameter, SensitiveParameterValue, the Random Engine interfaces, and ODBC connection-string helpers. It also provides ini_parse_quantity(). These are runtime shims for code that expects the native PHP 8.2 API on lower PHP versions.
- Does symfony/polyfill-php82 have a performance impact?
- There is no meaningful performance cost in typical Laravel applications. On PHP 8.2 and above, native implementations are used and the polyfill has no hot-path impact. On older PHP, the shims add only lightweight function and class definitions. The assessment cites roughly 0.1ms per request on PHP 8.2 and above.
- Is symfony/polyfill-php82 safe for production and cryptographic randomness?
- It is safe as a compatibility layer, but do not treat its Random Engine surface as a full replacement for every security-sensitive use case. The README points to arokettu/random-polyfill for additional engines. For cryptographic randomness on PHP below 8.2, review that package or native CSPRNG usage carefully. Run regression tests around any randomness-dependent code.
- What changed in symfony/polyfill-php82 v1.43.0 and can it break existing code?
- v1.43.0 is a semver-minor release with no new dependencies or Laravel integration changes. The assessment describes it as a correctness pass, so behavior on PHP below 8.2 can shift where the polyfill now matches native behavior more closely. If your app built workarounds around older divergent output, treat the upgrade as a behavioral change. Target those paths in regression tests before deploying.
- How should I test a symfony/polyfill-php82 upgrade in a Laravel app?
- Run the upgrade as an in-place Composer bump, flush caches and autoload, then execute your normal test suite on each supported PHP version. Add a focused diff test for any polyfilled functions your app actually uses. Grep for the provided class and function names to see whether the bump is close to a no-op. If you find custom shims or workarounds, remove them only after the upgrade is verified.