symfony/polyfill-php72
Symfony Polyfill for PHP 7.2: backports core and mbstring functions like spl_object_id, stream_isatty, mb_ord/mb_chr/mb_scrub, utf8_encode/decode, plus PHP 7.2 constants (PHP_FLOAT_*, PHP_OS_FAMILY) and Windows VT100 support.
This polyfill is typically used automatically by Laravel via Composer transitive dependencies—especially when targeting older PHP versions (e.g., 7.1) while using packages that rely on PHP 7.2+ features. To discover and use it directly:
composer show symfony/polyfill-php72 to inspect loaded version and autoloading.mb_ord('é') or use PHP_OS_FAMILY anywhere in your app.stream_isatty() for terminal detection.function_exists() checks before calling polyfilled functions (e.g., if (!function_exists('mb_scrub')) { ... }), though the polyfill guarantees availability.app/helpers.php) for consistent behavior across legacy and modern PHP environments.stream_isatty(STDOUT) in custom Artisan commands to conditionally enable colored output only on terminals.phpunit.xml, enforce minimal PHP version while testing fallback logic on polyfill-enabled environments (e.g., unit tests for Unicode-safe string processors).require needed—but misconfigurations (e.g., OPcache clearing issues) may cause intermittent missing functions; run composer dump-autoload -o after updates.polyfill-php73/74: Avoid installing multiple conflicting polyfills; prefer Symfony’s official polyfill chain (e.g., symfony/polyfill-php80 may supersede older ones). Check composer why symfony/polyfill-*.sapi_windows_vt100_support() only works on Windows CLI; do not assume it exists on non-Windows OSes—even if the polyfill is installed.utf8_encode/utf8_decode deprecation: These are deprecated in PHP 8.2+ and used only for legacy compatibility. Prefer mb_convert_encoding() in modern code, even with this polyfill active.function_exists() only to guard polyfill-specific behavior (e.g., fallback mocks in tests).How can I help you explore Laravel packages today?