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

symfony/polyfill-php83

Symfony Polyfill for PHP 8.3: backports core features like json_validate, Override attribute, mb_str_pad, str_increment/str_decrement, Date/SQLite3 exception classes, and updated ldap/stream context signatures for older PHP versions.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer: composer require symfony/polyfill-php83. No configuration needed—just require it and start using PHP 8.3 features like json_validate(), mb_str_pad(), str_increment(), #[Override], and exception classes (DateException, SQLite3Exception) immediately—even on PHP 7.2+ environments. This makes it ideal for legacy Laravel apps or packages needing to support older PHP versions while writing modern code.

Implementation Patterns

  • Write forward-compatible code: Use #[Override] on overridden methods in Laravel service providers or traits, or call mb_str_pad('test', 10, ' ', MB_CASE_UPPER) in string utilities—without version guards.
  • Unified exception handling: In Laravel’s app/Exceptions/Handler.php, catch DateException or SQLite3Exception consistently across PHP 7.x and 8.x without fallback Error handling.
  • Testing consistency: Write tests in modern PHP (e.g., using json_validate($json)), then run across PHP 7.4, 8.0, and 8.2 to guarantee behavior parity with polyfill + core.
  • Library development: Package authors targeting broad PHP ranges (e.g., Laravel package maintainers) rely on this to expose modern APIs (like str_increment()) without version-based branching in production code.

Gotchas and Tips

  • Performance is zero on PHP 8.3+: The polyfill auto-disables itself on PHP ≥8.3—no runtime overhead or fallback calls occur.
  • No override conflicts: Polyfills are only loaded if the native feature doesn’t exist; they never overwrite user-defined functions or built-ins.
  • IDE awareness: #[Override] may trigger IDE warnings (e.g., in PhpStorm or VS Code) if the PHP version interpreter isn’t set to 8.3+; configure phpstan/psalm with neon/xml config to enable strict checking (e.g., phpstan/phpstan-php83 extension).
  • Deprecation traps: Functions like ldap_connect_wallet() and ldap_exop_sync() are polyfilled despite being deprecated in PHP 8.3—avoid them in new code unless supporting legacy LDAP systems.
  • Test explicitly for polyfill: When debugging, confirm via ReflectionFunction::getName() or class_exists(DateException::class) if you rely on polyfill behavior; never assume native equality (e.g., edge cases in mb_str_pad() padding with MB_CASE_* flags).
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