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 Php84

Polyfill Php84 Laravel Package

symfony/polyfill-php84

Symfony Polyfill for PHP 8.4 features, enabling newer core functions and APIs on older runtimes. Includes array_find/any/all, bcdivmod, Deprecated attribute, fpow, grapheme_str_split, mb_* trim/ucfirst/lcfirst, PDO subclasses, and ReflectionConstant.

View on GitHub
Deep Wiki
Context7

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

Frequently asked questions about Polyfill Php84
Can I use `array_find` from PHP 8.4 in Laravel 9/10 without upgrading PHP?
Yes. This polyfill provides `array_find`, `array_all`, and `array_any` as drop-in replacements. They work identically to Laravel’s Collection methods like `firstWhere` but with native PHP 8.4 behavior. Test edge cases (e.g., associative arrays) to ensure consistency with your existing logic.
How do I install this polyfill for Laravel?
Add it via Composer: `composer require symfony/polyfill-php84`. No Laravel-specific configuration is needed—it autoloads like any other Composer package. Works with Laravel 9/10 and PHP 7.4–8.3.
Will this break my Laravel app if I use it?
No, polyfills are backward-compatible. They replace missing PHP 8.4 functions without altering existing code. However, test critical paths (e.g., collections, database queries) to confirm behavior matches your expectations, especially with edge cases like empty arrays or multibyte strings.
Does this polyfill support Laravel’s Eloquent or database layer?
Yes. The PDO polyfills stabilize Eloquent and query builder interactions, particularly in environments with SSL constraints (e.g., financial apps). Test transactions, connection pooling, and custom drivers to ensure no regressions, especially if you rely on PDO-specific features.
What’s the performance impact of using these polyfills in Laravel?
Polyfills add minimal overhead (~1MB to vendor size). Benchmark critical paths (e.g., API routes) to compare performance with native PHP 8.4 functions. For example, test `array_find` in collections or `mb_trim` in form validation to measure real-world impact.
Does this polyfill require PCRE 10.44+ for grapheme_str_split?
Yes. The `grapheme_str_split` polyfill requires PCRE ≥10.44. Check your hosting environment with `version_compare(PCRE_VERSION, '10.44')` and add a runtime check (e.g., `Log::warning`) if unsupported. Upgrade PCRE or use a fallback for unsupported setups.
Can I use the #[Deprecated] attribute in Laravel with this polyfill?
Yes. The `Deprecated` attribute polyfill enables PHP 8.4’s native deprecation syntax in Laravel 9/10. Use it for marking methods/classes as deprecated in your codebase, which will trigger PHP’s deprecation warnings as expected.
Are there alternatives to this polyfill for Laravel?
Native PHP 8.4 is the ideal long-term solution, but this polyfill is the most robust alternative. Other options like `ext-mbstring` or custom implementations lack the comprehensive feature set (e.g., PDO subclasses, `fpow`). Symfony’s polyfill is actively maintained and integrates seamlessly with Laravel’s ecosystem.
How do I test if this polyfill works correctly in my Laravel app?
Write unit tests for critical paths using Laravel’s PHPUnit. Compare outputs of polyfilled functions (e.g., `array_find`) with PHP 8.4’s native behavior. Focus on edge cases like empty arrays, multibyte strings (e.g., emojis), and database interactions with PDO polyfills.
What’s the long-term strategy for using this polyfill in Laravel?
Treat this as a temporary bridge to PHP 8.4. Monitor Symfony’s polyfill roadmap and plan to remove it when your Laravel app supports PHP 8.4+. Document the polyfill’s purpose in your codebase and set a timeline for its removal to avoid dependency bloat.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony