- How do I use symfony/polyfill-php73 in a Laravel project?
- Install it via Composer with `composer require symfony/polyfill-php73`. No additional Laravel configuration is needed—it autoloads polyfills conditionally based on your PHP version. Use the polyfilled functions (e.g., `array_key_first()`) just like native PHP 7.3+ methods.
- What PHP versions does symfony/polyfill-php73 support?
- It works on PHP 5.3 through 7.2, providing the missing PHP 7.3 features. On PHP 7.3+, the polyfills are silently ignored, ensuring zero runtime overhead. Laravel’s minimum PHP version (5.6+) is fully compatible.
- Will this package conflict with Laravel’s existing symfony/polyfill?
- No, it integrates seamlessly. If Laravel already includes `symfony/polyfill`, this package may be redundant—check your `vendor/symfony/polyfill` for existing PHP 7.3 polyfills. Use `composer show symfony/polyfill` to verify.
- Does symfony/polyfill-php73 add performance overhead?
- Minimal. Polyfills are lazy-loaded and add negligible overhead (typically <0.1ms). Benchmark critical paths (e.g., `hrtime()` in timing-sensitive code) in a staging environment to confirm.
- Can I use JsonException from this polyfill in Laravel’s API responses?
- Yes. The `JsonException` polyfill works identically to PHP 7.3’s native class. Use it for robust JSON error handling in Laravel’s HTTP responses or API contracts without requiring PHP 7.3.
- How do I verify this is the official Symfony package and not a malicious fork?
- Check the package source via `composer show symfony/polyfill-php73` and confirm it points to Symfony’s official GitHub repository. Pin the version (e.g., `1.37.0`) in `composer.json` and validate the source hash against Symfony’s repository.
- What if my Laravel app already manually implements array_key_first()?
- Avoid conflicts by auditing your codebase for custom polyfills/shims. If duplicates exist, refactor to use this package’s version or disable the polyfill via Composer’s `replace` directive in `composer.json`.
- Is this package safe for production use in Laravel?
- Yes, it’s widely used in Symfony and Laravel ecosystems. Test critical paths (e.g., Eloquent collections with `array_key_first()`) in staging. The MIT license ensures no legal risks, and Symfony’s maintenance guarantees stability.
- What happens if I upgrade to PHP 8.x in the future?
- Polyfills are automatically ignored on PHP 7.3+. If you upgrade to PHP 8.x, remove this package via `composer remove symfony/polyfill-php73`—native implementations will replace the polyfills seamlessly.
- Are there alternatives to symfony/pphp73 for Laravel?
- For PHP 7.3 features, alternatives are limited. Other polyfill suites (e.g., `ramsey/array_functions`) may cover some functions but lack Symfony’s ecosystem integration. This package is the most Laravel-friendly option for PHP 7.3 compatibility.