symfony/polyfill-php86
Symfony Polyfill Php86 brings upcoming PHP 8.6 features to older runtimes. Includes the clamp() function, ARRAY_FILTER_USE_VALUE constant, and the SortDirection enum. Ideal for forward-compatible code while staying on PHP 8.x.
clamp() for input validation or SortDirection for API consistency, extending the usable lifespan of existing codebases.clamp implementations) by providing a battle-tested, MIT-licensed solution maintained by Symfony. Reduces technical debt and maintenance overhead.clamp() to sanitize user inputs (e.g., capping prices, ratings, or quantities) without manual min/max checks.SortDirection enum across microservices or monoliths, ensuring consistency even when some services run older PHP versions.ARRAY_FILTER_USE_VALUE to simplify array operations (e.g., filtering collections) without upgrading to PHP 8.1+ dependencies.clamp, SortDirection, ARRAY_FILTER_USE_VALUE) for new functionality or compliance.polyfill-intl, polyfill-ctype), ensuring consistency in the dependency ecosystem.grapheme_strrev is niche; evaluate whether it’s critical for your workflow)."This package lets us use PHP 8.6’s advanced features today—like clamp() for input validation or SortDirection for APIs—without upgrading our entire infrastructure. It’s a low-risk, high-reward way to future-proof our codebase, reduce technical debt, and align with modern PHP standards. Think of it as ‘PHP 8.6 on demand’ for legacy systems: we get the benefits of newer features now, while keeping our current PHP version. This supports our roadmap for gradual upgrades and reduces the cost of migrating to newer PHP versions later. It’s also MIT-licensed and maintained by Symfony, so we’re not betting on a one-person open-source project."
*"Symfony’s polyfill-php86 gives us three powerful PHP 8.6 features backported to older versions, with zero effort:
clamp() – Cleaner value capping (e.g., for user inputs, financial calculations). Replace manual min/max checks with a single function call.SortDirection enum – Type-safe sorting for APIs and collections. No more magic strings like 'ASC'/'DESC'—just a proper enum.ARRAY_FILTER_USE_VALUE – Simpler array filtering in Laravel/Symfony. Write array_filter($array, fn($v) => $v > 10, ARRAY_FILTER_USE_VALUE) instead of workarounds.Why use it?
How to start?
composer.json: composer require symfony/polyfill-php86.clamp() in validation, SortDirection in APIs).Risks?
composer why-not-remove can help clean up later).This is a no-brainer for teams already using Symfony/Laravel polyfills—it’s the same ecosystem, same quality, and same support."*
How can I help you explore Laravel packages today?