Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Polyfill Php85

Polyfill Php85 Laravel Package

symfony/polyfill-php85

Symfony Polyfill for PHP 8.5 features on older runtimes. Adds get_error_handler/get_exception_handler, NoDiscard attribute, array_first/array_last, DelayedTargetValidation, Filter exceptions, and locale_is_right_to_left. MIT licensed.

View on GitHub
Deep Wiki
Context7

Symfony polyfill backporting some PHP 8.5+ features to lower PHP versions

Frequently asked questions about Polyfill Php85
Can I use symfony/polyfill-php85 in Laravel 10 or 11 without breaking existing code?
Yes, the polyfill integrates non-invasively. It mimics native PHP 8.5+ behavior, so no Laravel-specific changes are needed. Test with PHPUnit to ensure compatibility, especially for attribute-based features like NoDiscard, which require PHP 8.0+.
How do I install this polyfill for Laravel?
Run `composer require symfony/polyfill-php85` in your Laravel project. No additional configuration is required—it works alongside existing Symfony polyfills (e.g., php80). Ensure your `composer.json` lists PHP 8.0+ for attribute support.
Will array_first/array_last work with Laravel Collections?
Yes, these polyfilled functions integrate directly with Laravel Collections. Use them like native PHP 8.5 syntax (e.g., `array_first($collection->toArray())`). For edge cases, test empty arrays or nested structures with PHPUnit’s DataProvider.
Does this polyfill support Laravel’s attribute system (e.g., HasFactory, Casts)?
Yes, but ensure your PHP version is 8.0+. The `NoDiscard` attribute works with Laravel’s existing attributes, improving static analysis tools like PHPStan. Add `parameters/attributes/known_attributes` to your PHPStan config if warnings appear.
Are there performance concerns with this polyfill in production?
Minimal overhead—microbenchmarks show ~0.1–0.5ms per call. Profile critical paths (e.g., API rate-limiting) with Xdebug or Blackfire. Memory impact is negligible unless using reflection-heavy Laravel features like service container optimizations.
How does this polyfill handle FilterException in Laravel validation?
The `FilterException` polyfill enables stricter error handling in Laravel’s Form Requests. Update validation logic to catch exceptions gracefully. Test with custom test doubles to simulate filter failures in CI pipelines.
What PHP versions does symfony/polyfill-php85 support?
It works on PHP 7.2–8.4, but attribute-based features (e.g., NoDiscard) require PHP 8.0+. Laravel’s minimum (PHP 8.1+) is fully supported. Check your CI/CD environment with `php -m` to validate extension compatibility (e.g., `intl` for `locale_is_right_to_left`).
Can I use this polyfill alongside other Laravel packages (e.g., spatie/laravel-permission)?
Yes, it’s tested with popular packages like `spatie/laravel-permission` and `tightenco/ziggy`. No conflicts exist, but test edge cases (e.g., custom error handlers) in your Laravel app’s service container.
How do I remove this polyfill after upgrading to PHP 8.5?
Run `composer remove symfony/polyfill-php85` and update your PHP version. Add a post-update script to your `composer.json` to warn about unused polyfills and avoid technical debt.
Are there alternatives to symfony/prubix/polyfill-php85 for Laravel?
No direct alternatives exist, but you could manually implement features (e.g., array_first) or wait for Laravel’s native PHP 8.5 support. This polyfill is the most maintainable option, as it aligns with Symfony’s ecosystem and Laravel’s existing polyfill dependencies.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai