- What is symfony/polyfill-php85 and which PHP 8.5 features does it backport?
- It is a Symfony polyfill that backports selected PHP 8.5 features to lower PHP versions. It provides get_error_handler and get_exception_handler, NoDiscard, array_first and array_last, DelayedTargetValidation, FilterException and FilterFailedException, and locale_is_right_to_left. Laravel apps can use these APIs without upgrading every environment to PHP 8.5.
- How do I install symfony/polyfill-php85 in a Laravel application?
- Install it with Composer using composer require symfony/polyfill-php85. It is loaded through Composer autoloading and requires no Laravel service provider or config changes. Run composer validate and your test suite afterward to confirm dependency compatibility.
- Is symfony/polyfill-php85 compatible with Laravel 10 and Laravel 11?
- The evaluation tested Laravel 10.x and 11.x with major packages such as spatie/laravel-permission and tightenco/ziggy and found no known conflicts. Compatibility still depends on your exact dependency set, so validate with Composer and run your application tests before deploying. It fits naturally alongside Laravel's existing Symfony polyfill dependencies.
- Do I need any Laravel configuration after installing symfony/polyfill-php85?
- No Laravel-specific configuration is required. The package is a runtime-only polyfill loaded through Composer, so you can call functions such as array_first directly in your code. For IDE support, add PHPDoc stubs or configure PHPStorm or VS Code to recognize vendor/symfony/polyfill-php85.
- Which PHP versions does symfony/polyfill-php85 support?
- It is designed to backport PHP 8.5 features to lower PHP versions, bridging legacy environments such as PHP 7.4 through 8.4. Attribute-based features like NoDiscard and DelayedTargetValidation require PHP 8.0 or newer. On PHP 8.5 environments the native implementations are used instead.
- Can I use array_first and array_last in Laravel Collections with this polyfill?
- Yes, the polyfill provides array_first and array_last so you can use those PHP 8.5 functions on older PHP versions. They complement Laravel Collection methods and are useful in edge cases where you need array semantics rather than a Collection pipeline. Test empty arrays and key behavior in your own code paths.
- How should I test PHP 8.5 polyfill features in a Laravel app?
- Use PHPUnit data providers to exercise the features across PHP 8.0 through 8.4. Skip attribute tests below PHP 8.0 and include cases for empty arrays, FilterException in FormRequest validation, and locale-aware sorting. Because v1.43.0 fixed argument validation in grapheme_levenshtein and grapheme_str_split, add multibyte string and i18n regression tests before and after upgrading.
- What production risks should I consider before using symfony/polyfill-php85?
- Polyfills can partially emulate PHP 8.5 behavior, so edge cases may differ from native PHP 8.5. The v1.43.0 release narrows intl-related gaps, but the intl emulation layer is younger and more defect-prone than the core scalar and array polyfills. Run regression tests for locale sorting, RTL detection, multibyte helpers, and filter exceptions before relying on it in production.
- How does symfony/polyfill-php85 support RTL locales and internationalization in Laravel?
- It provides locale_is_right_to_left plus intl-emulation features such as grapheme_* helpers, Collator sorting, and MessageFormatter. These are useful for Laravel admin panels with RTL locales, locale-aware sort ordering, and translated message formatting. Treat this surface as newer and test it thoroughly in your target locales.
- What alternatives exist to symfony/polyfill-php85 for older PHP versions?
- The cleanest alternative is running PHP 8.5 natively. You can also stay within the Symfony polyfill ecosystem, such as symfony/polyfill-php80 and php81, for consistency with Laravel dependencies. Custom polyfills are possible but add maintenance overhead and risk diverging from Symfony's tested implementations.