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

symfony/polyfill-php81

Symfony Polyfill for PHP 8.1 features on older runtimes: array_is_list, enum_exists, MYSQLI_REFRESH_REPLICA constant, ReturnTypeWillChange, and CURLStringFile (PHP 7.4+). Part of the Symfony Polyfill suite, MIT licensed.

View on GitHub
Deep Wiki
Context7

Getting Started

This polyfill is typically used automatically by Composer when your project declares a minimum PHP version (e.g., php: "^7.4") but uses PHP 8.1+ features like array_is_list() or enum_exists(). No manual setup is required — just require a package that depends on symfony/polyfill-php81 (e.g., most modern Symfony components or Laravel packages targeting older PHP versions). To verify it’s active, call array_is_list([]) or enum_exists(MyEnum::class) on a PHP <8.1 environment — if it works without fatal errors, the polyfill is loaded.

Implementation Patterns

  • Safe feature usage in libraries: Package authors target PHP 7.4+ but use enum_exists() or array_is_list() directly — the polyfill ensures compatibility across versions.
  • Laravel integration: When writing custom helpers or service providers, developers use enum_exists() to conditionally handle enums in Laravel apps running on PHP 8.0 or lower (e.g., legacy deployments).
  • Middleware or trait-based guards: In code shared across environments, use array_is_list($data) before iterating to avoid subtle bugs when array keys are non-sequential — safe for PHP <8.1 without extra function_exists() checks.

Gotchas and Tips

  • Autoload priority: The polyfill is self-registering via Composer\Autoload\ClassLoader, but ensure your autoloader runs before any polyfill-reliant code (standard Composer setup handles this).
  • No runtime detection needed: Avoid wrapping calls like function_exists('array_is_list') — the polyfill guarantees availability unconditionally.
  • Partial coverage: Only the listed features above are backported — for example, readonly properties or final class constants in traits from PHP 8.1 are not supported here (they require actual engine support).
  • Extension points: If you need more features (e.g., PHP 8.2 support), consider symfony/polyfill-php82 — avoid mixing manual polyfills to prevent conflicts.
  • Debugging: If you see "undefined function" errors despite expecting the polyfill, check for conflicting autoloader configurations or outdated Composer versions (<2.2) that may fail to load polyfills properly.
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