Weave 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 Iconv

Polyfill Iconv Laravel Package

symfony/polyfill-iconv

Native PHP implementation of the iconv functions (except ob_iconv_handler) for environments lacking the iconv extension, provided as part of the Symfony Polyfill project.

View on GitHub
Deep Wiki
Context7

symfony/polyfill-iconv provides a pure-PHP implementation of PHP's iconv functions, letting applications convert strings between character encodings even when the native iconv extension is unavailable or disabled. It is part of the Symfony Polyfill family, designed as a transparent drop-in for environments with limited PHP builds.

  • Ships native PHP equivalents of iconv(), iconv_strlen(), iconv_substr(), iconv_strpos(), and iconv_strrpos()
  • Enables portable character-encoding conversion across hosts, containers, and shared servers
  • Integrates automatically via Composer autoloading—no configuration required
  • Excludes only ob_iconv_handler, keeping the scope focused and lightweight
  • Released under the permissive MIT license
Frequently asked questions about Polyfill Iconv
What is symfony/polyfill-iconv used for in Laravel?
It is a pure PHP fallback for the iconv extension, so Laravel apps can keep using iconv() for character set conversion when ext-iconv is missing or inconsistent across environments. It requires no Laravel-specific configuration and is loaded through Composer autoloading. It is most useful for multilingual content, legacy integrations, and compliance-sensitive data workflows.
How do I install symfony/polyfill-iconv in a Laravel project?
Install it with composer require symfony/polyfill-iconv. In many cases it is already pulled in transitively by other Symfony packages, so check composer show before adding it directly. No service provider or config change is needed; the polyfill defines the missing functions automatically.
Does symfony/polyfill-iconv work without the PHP iconv extension?
Yes. The package provides a native PHP implementation of common iconv functions and is designed to be used when ext-iconv is unavailable. The main exception noted in the evaluation is ob_iconv_handler, and iconv_get_encoding() is also listed as unsupported, so those cases need workarounds.
Which iconv functions are supported by symfony/polyfill-iconv?
It implements common iconv functions used for character set conversion, short of ob_iconv_handler per the README. The technical evaluation also flags iconv_get_encoding() as unsupported. For unsupported output-buffering or encoding-detection behavior, use mbstring or explicit application logic.
Is symfony/polyfill-iconv compatible with Laravel 10 and Laravel 11?
It is framework-agnostic and installed via Composer, so it works with Laravel 10 and Laravel 11 when your PHP and Composer constraints allow it. Because PHP 8.2+ and Laravel 11+ may change iconv behavior, validate encoding edge cases during upgrades. Monitor Symfony release notes and Laravel dependency updates for compatibility.
How does symfony/polyfill-iconv affect performance in production?
The polyfill is typically 2–5 times slower than native ext-iconv for encoding operations, which can matter in high-throughput APIs or batch jobs. Profile with Blackfire or Laravel Telescope to find bottlenecks, and enable ext-iconv in production where possible. Cache frequent conversions or precompute encoded values to reduce overhead.
How can I test a Laravel app with symfony/polyfill-iconv enabled?
Run your test suite with iconv disabled, for example php -d extension=-iconv artisan test, and use function_exists('iconv') checks to confirm the polyfill path. Add PHPUnit cases for Arabic, CJK, and other real-world encoding edge cases. This helps catch data corruption before production.
What are the alternatives to symfony/polyfill-iconv for character encoding in Laravel?
The best alternative is enabling native ext-iconv, which avoids the polyfill performance overhead. If that is not possible, use mbstring functions and symfony/polyfill-mbstring where needed, or wrap conversions in your own encoding service. This polyfill remains the drop-in option for code that already calls iconv().
Does symfony/polyfill-iconv handle multilingual and legacy encodings like Arabic, CJK, or EBCDIC?
It covers common character set conversions, but the evaluation warns that complex scripts such as Thai and Arabic and obscure encodings such as EBCDIC may have edge-case failures. Test with real-world datasets like Unicode CLDR and log any encoding artifacts in production. Do not assume full parity with native iconv for every legacy encoding.
How is symfony/polyfill-iconv maintained and updated?
It is a Symfony-maintained, MIT-licensed package, so updates follow Symfony’s release and maintenance cycle. Keep an eye on Symfony release notes and Laravel dependency updates for PHP 8.3+ and Laravel 11+ compatibility. Because it adds about 1MB to vendor size, avoid unnecessary direct dependencies in CI/CD.
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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core