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

Polyfill Php83 Laravel Package

symfony/polyfill-php83

Symfony Polyfill for PHP 8.3 features on older runtimes. Adds json_validate, Override attribute, mb_str_pad, str_increment/str_decrement, updated LDAP/stream context signatures, Date/SQLite3 exception classes, and more.

View on GitHub
Deep Wiki
Context7

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

Frequently asked questions about Polyfill Php83
Can I use symfony/polyfill-php83 in Laravel to support PHP 8.3 features on PHP 7.4 or 8.0?
Yes, this polyfill bridges the gap by providing PHP 8.3 APIs like `json_validate()` and `#[Override]` on older runtimes. It’s framework-agnostic but integrates seamlessly with Laravel’s exception handling and string utilities. No Laravel-specific setup is required—just add it via Composer.
How do I install symfony/polyfill-php83 in a Laravel project?
Run `composer require symfony/polyfill-php83:^1.34.0` in your project root. The package auto-detects missing PHP 8.3 features and polyfills them without manual configuration. No service providers, facades, or Laravel-specific changes are needed.
Will this polyfill work with Laravel’s built-in Validator for JSON validation?
Yes, the `json_validate()` function can replace or augment Laravel’s Validator for JSON payloads. It’s faster than parsing with `json_decode()` and integrates cleanly with Laravel’s validation pipeline. Use it in custom rules or middleware for API security.
Does symfony/polyfill-php83 support the #[Override] attribute for Laravel’s service providers or traits?
Absolutely. The polyfill provides the `#[Override]` attribute to suppress PHP warnings when overriding methods in Laravel’s service providers, traits, or controllers. This reduces runtime deprecation notices and improves code clarity.
Are there any known issues with mb_str_pad() in Laravel when using this polyfill?
Version 1.34.0 fixed edge cases with `mb_str_pad()`, but it may now throw errors for invalid inputs (e.g., objects or null) that were previously ignored. Audit your `mb_*` function calls post-installation, especially in localization-heavy apps.
Will this polyfill break existing Laravel applications or require PHPStan/Psalm updates?
No breaking changes occur, but static analysis tools like PHPStan or Psalm may flag PHP 8.3 features as unsupported unless configured for PHP 8.3. Install plugins like `phpstan/phpstan-php83` to resolve false positives.
Can I use str_increment() and str_decrement() in Laravel for versioning or sequential IDs?
Yes, these functions provide saner increment/decrement behavior for strings (e.g., ‘v1.0’ → ‘v1.1’). They’re useful for Laravel’s versioning systems, sequential filenames, or custom ID generation without regex or manual logic.
Is symfony/polyfill-php83 compatible with Laravel’s exception handling (e.g., app/Exceptions/Handler.php)?
Yes, the polyfill’s `DateException` and `SQLite3Exception` classes integrate with Laravel’s exception hierarchy. They’ll be caught by your existing `Handler` and logged/rendered as expected, maintaining consistency with Laravel’s error handling.
What’s the performance impact of using this polyfill in production?
Negligible. The polyfill only activates missing PHP 8.3 features, adding minimal overhead. Benchmarks show no measurable difference in Laravel’s request handling when using `json_validate()` or `mb_str_pad()` compared to native PHP 8.3.
Are there alternatives to symfony/polyfill-php83 for specific features like json_validate?
For `json_validate()`, alternatives like `spatie/php-json-validator` exist, but they lack the broader PHP 8.3 feature set. This polyfill is ideal if you need multiple features (e.g., `#[Override]`, `mb_str_pad`) or want a single, maintained dependency. Evaluate trade-offs based on your project’s needs.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai