symfony/polyfill-apcu
Symfony Polyfill for APCu: provides compatible APCu functions/constants for PHP environments where the extension is missing or incomplete. Helps libraries rely on APCu-style caching across versions and platforms with a lightweight fallback implementation.
Install via Composer: composer require symfony/polyfill-apcu. No configuration needed—it auto-registers fallbacks for apcu_* functions when the APCu extension isn’t loaded (e.g., PHP < 5.5, shared hosting, Docker containers without extension). If your app already uses functions like apcu_store() or apcu_fetch(), they’ll work out-of-the-box on environments lacking the native extension. Start by verifying your code already relies on APCu; this polyfill doesn’t add new functionality—it only ensures existing APCu calls succeed.
composer.json ("suggest": {"symfony/polyfill-apcu": "..."}) so consumers can opt-in—avoid forcing installation on environments where APCu is guaranteed (e.g., modern Laravel apps with ext-apcu).ApcuStore) that fall back to APCu functions internally. Laravel’s Cache::driver('apcu') won’t auto-fallback, but your custom implementation can leverage this polyfill seamlessly.ext-apcu to validate compatibility. The polyfill ensures tests relying on APCu functions pass without mocking or environment-specific branching.apc.enabled=0, the extension’s stub functions are loaded, and the polyfill won’t activate. Confirm via php -m | grep apcu; if present, the polyfill is ignored.apcu_cas, apcu_inc, apcu_dec. Use function_exists('apcu_inc') before calling optional functions, or check source for exact API parity.serialize(), which may alter object metadata (e.g., __wakeup() timing, static property loss). Test edge cases—especially if caching complex objects.vendor/autoload.php). If manually loading files (e.g., custom bootstraps), ensure polyfill loads before any apcu_* calls.How can I help you explore Laravel packages today?