symfony/polyfill-php84
Symfony Polyfill for PHP 8.4 features on older runtimes. Adds helpers like array_find/array_any/array_all, bcdivmod, Deprecated attribute, fpow, grapheme_str_split, mb_* trim/ucfirst/lcfirst, ReflectionConstant, and CURL HTTP/3 constants.
composer require symfony/polyfill-php84. No additional setup is required—autoloading is handled automatically by Composer.array_find, array_any, etc.) in your Laravel app while targeting PHP 8.1+ (or even 8.0, per polyfill docs). For example:
$result = array_find($users, fn($user) => $user->isActive());
This works identically to PHP 8.4’s native implementation, even on older PHP versions.Illuminate\Support\Arr::first()—especially useful for cross-framework or multi-version projects.bcdivmod($a, $b, 2)).grapheme_str_split()), so avoid naming conflicts with custom functions.array_all vs. manual foreach.Deprecated attribute usage: The polyfill only enables the #[Deprecated] attribute to function as a hint—it does not emit deprecation warnings automatically. You still need to handle deprecation logic yourself (e.g., using trigger_deprecation()).grapheme_str_split() and mb_* polyfills may fall back to less robust implementations if ext-intl/ext-gettext aren’t installed. Ensure production environments meet polyfill requirements (check bootstrap.php in the package).function_exists('array_any') to conditionally polyfill only when needed (rarely required, but useful for custom bootstrap layers).How can I help you explore Laravel packages today?