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 Php73

Polyfill Php73 Laravel Package

symfony/polyfill-php73

Symfony Polyfill for PHP 7.3: provides fallback implementations of core features for older PHP versions, including array_key_first/last, hrtime, is_countable, and JsonException, ensuring consistent behavior across environments.

View on GitHub
Deep Wiki
Context7

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

Frequently asked questions about Polyfill Php73
How do I install symfony/polyfill-php73 in a Laravel project?
Run `composer require symfony/polyfill-php73` in your Laravel project’s root directory. The package integrates automatically via Composer’s autoloader and requires no additional Laravel-specific configuration. It’s conditionally loaded only on PHP versions below 7.3, ensuring zero overhead on modern PHP.
Will this package conflict with Laravel’s existing symfony/polyfill dependencies?
Unlikely, but check your `vendor/symfony/polyfill` directory for overlapping features like `array_key_first`. If Laravel already includes these polyfills (e.g., via Symfony’s core bundle), this package may be redundant. Audit your dependencies to avoid duplication, or pin to a specific version to ensure consistency.
Does symfony/polyfill-php73 support Laravel 5.5+ or only newer versions?
This package is compatible with Laravel 5.5+ and up to Laravel 9.x, as it aligns with Symfony’s polyfill strategy already embedded in Laravel’s core. No Laravel-specific changes are required—it works as a drop-in solution for older PHP environments without breaking newer Laravel versions.
How can I test if the polyfills are working correctly in my Laravel app?
Write unit tests targeting the polyfilled functions (e.g., `array_key_first` on Eloquent collections or `JsonException` in API responses). Use PHPUnit to verify behavior matches PHP 7.3+ standards. For example, test `array_key_first([])` returns `null` and `JsonException` propagates correctly in JSON parsing logic.
Is there a performance impact when using this package on PHP 7.3+?
No, the polyfills are dynamically skipped on PHP 7.3+, adding **zero runtime overhead**. The package only activates on older PHP versions (e.g., 7.2 or below), where it introduces minimal latency (~0.1ms per call). Benchmark critical paths in staging if performance is a concern, but the impact is negligible for most Laravel applications.
Can I use hrtime from this polyfill for microbenchmarking in Laravel middleware or jobs?
Yes, the `hrtime` polyfill provides high-resolution timing for performance-critical paths like middleware, queue jobs, or API rate-limiting. Use it to measure execution time in milliseconds or nanoseconds, but note that results may vary slightly between PHP versions. For consistency, test on your target PHP environment.
What happens if I deploy this package on PHP 8.0+? Will it break anything?
Nothing will break—the polyfills are **automatically disabled** on PHP 7.3+. The package is designed to be a no-op on modern PHP, so you can safely deploy it without side effects. It’s ideal for environments where some servers run PHP 7.2 and others run PHP 8.0+.
Are there any alternatives to symfony/ppolyfill-php73 for Laravel?
Laravel’s core already includes some polyfills via `symfony/polyfill`, so check if `array_key_first` or `JsonException` are already covered. For broader PHP 7.3+ features, consider `symfony/polyfill-php80` or `ramsey/collection` for advanced collection methods. However, Symfony’s polyfills are the most widely tested and Laravel-compatible option.
How do I ensure I’m using the official Symfony release and not a malicious version?
Pin the package to a specific version in `composer.json` (e.g., `symfony/polyfill-php73:^1.37.0`) and verify the source via Symfony’s [GitHub repository](https://github.com/symfony/polyfill-php73). Cross-reference the package hash with Symfony’s official releases to confirm integrity. Avoid using `*` or loose version constraints.
Will this package help with JSON API error handling in Laravel?
Yes, the `JsonException` polyfill standardizes JSON parsing errors across PHP versions, making it easier to handle malformed API responses or webhook payloads. Replace ad-hoc `json_decode` error checks with `try { json_decode($data); } catch (JsonException $e) { ... }` for cleaner, more consistent error handling in Laravel APIs.
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/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
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