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 Laravel Package

symfony/polyfill-php73

Provides PHP 7.3 compatibility helpers for older runtimes via the Symfony Polyfill component. Adds missing functions and constants so libraries can target newer PHP features while still running on legacy versions, easing upgrades and dependency support.

View on GitHub
Deep Wiki
Context7

Getting Started

This package provides backward compatibility for PHP 7.3+ features (e.g., array_key_first(), array_key_last(), json_last_error_msg()) when running on older PHP versions (5.3+). To use it:

  • Install via Composer: composer require symfony/polyfill-php73
  • No manual bootstrap needed—Composer’s autoloader automatically loads polyfills when their functions/classes are missing.
  • First use case: write modern PHP 7.3+ code in your app (e.g., $firstKey = array_key_first($array);), and this polyfill ensures it works even on PHP 7.2.

Implementation Patterns

  • Transparent usage: Call PHP 7.3+ functions directly in your code; the polyfill detects availability and only defines them if not natively present.
  • Composer integration: No configuration required—Composer registers the polyfill via autoload_files.php (via symfony/polyfill’s root composer.json).
  • Framework compatibility: Works out-of-the-box with Laravel, Symfony, and other frameworks that rely on Composer autoloading.
  • Avoid duplication: If you define a polyfill manually elsewhere (e.g., in a custom bootstrap), ensure it doesn’t conflict—this package’s functions are conditionally defined only when missing.

Gotchas and Tips

  • No runtime impact on PHP 7.3+: Functions are only defined when missing, so there’s zero performance overhead on modern PHP versions.
  • No backward compat shims: This polyfill only backports core language functions—it doesn’t provide full backward compatibility (e.g., won’t backport abstract trait methods or type hints).
  • Never need require/include: Rely solely on Composer’s autoloader; manually including files can cause redeclaration errors.
  • Debug tip: Check if a polyfill is active by calling function_exists('array_key_first') before using it (though unnecessary in most cases).
  • Extension point: If you use a custom autoloader (e.g., non-Composer setup), manually include vendor/symfony/polyfill-php73/bootstrap.php (but avoid this unless absolutely necessary).
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport