APCu extension (php_apcu.dll) will not load on Windows with PHP 8
Call to undefined function apcu_fetch()Short answer
PHP only loads an extension DLL that matches your PHP build: same version line, thread safety, architecture and debug setting. Download the APCu DLL from the PECL page for that exact build, put it in the folder set by extension_dir, add extension=apcu to the php.ini PHP really loads, and restart.
Fix it fast
1Find out which cause you have
Ask PHP which build it is and which php.ini and extension folder it uses. Match the DLL to this output.
php -i | findstr /C:"Thread Safety" /C:"Architecture" /C:"Loaded Configuration File" /C:"extension_dir" /C:"PHP Version"2Match what you see, then jump to its fix
- 1
php -m does not list apcu, though the DLL file existsThe DLL does not match your PHP buildFix - 2
php -m does not list apcu and the DLL is not where extension_dir pointsThe DLL is in the wrong folder, or extension_dir is wrongFix - 3
php -m lists apcu but the website says Call to undefined function apcu_fetch(), or the reverseThe extension line is in a php.ini that is not loaded, or the server was not restartedFix - 4
The DLL is in place and listed, but APCu still does not workAPCu has no writable temp folder on WindowsFix
- 1
What does the error look like?
Call to undefined function apcu_fetch()php_apcu.dll missing for PHP 8.2 (APCu 5.1.22)
Cause 1 of 4
The DLL does not match your PHP build
1Check
The manual says DLLs differ by version number (at least the first two numbers must match), thread safety, processor architecture and debug setting. Compare the Thread Safety and Architecture lines from the first step with the name of the ZIP you downloaded.
php -i | findstr /C:"Thread Safety" /C:"Architecture" /C:"Debug Build"2Fix
Open the APCu page on pecl.php.net, use the Windows DLL link for a release that has a build for your PHP line, and take the ZIP that matches TS or NTS and x64 or x86 of your PHP.
:: copy only the extension DLL out of the downloaded ZIP
copy php_apcu.dll C:\php\ext\3Verify
Start PHP and read the extension list. No startup warning appears.
php -m | findstr /I apcuConfirmed by php.net
Cause 2 of 4
The DLL is in the wrong folder, or extension_dir is wrong
1Check
Extension DLLs belong in the ext folder, and extension_dir in php.ini must point to it with the full path.
php -r "echo ini_get('extension_dir');"
dir C:\php\ext\php_apcu.dll2Fix
Set extension_dir to the real ext folder and keep php_apcu.dll in it.
; php.ini
extension_dir = "C:\php\ext"3Verify
Run php -m again after saving php.ini.
php -m | findstr /I apcuConfirmed by php.net
Cause 3 of 4
The extension line is in a php.ini that is not loaded, or the server was not restarted
1Check
Check the Loaded Configuration File value for the CLI and in phpinfo() on the web server. Edit that file. Since PHP 7.2 you can write the extension name.
php --ini2Fix
Add the extension line to the loaded file and restart the web server.
; php.ini
extension=apcu3Verify
phpinfo() shows an apcu section after the restart.
php -r "var_dump(function_exists('apcu_fetch'));"Confirmed by php.net
Cause 4 of 4
APCu has no writable temp folder on Windows
1Check
On Windows APCu needs a temp path that exists and that the web server can write to. It reads the TMP, TEMP and USERPROFILE environment variables in that order, then falls back to the Windows directory.
echo %TMP% %TEMP%2Fix
Point TMP or TEMP at an existing folder that the web server account can write to, and restart the service.
setx TMP C:\Temp /M3Verify
Restart the web server and check that apcu is listed.
php -m | findstr /I apcuConfirmed by php.net
How do I stop it coming back?
- After every PHP upgrade, download new DLLs for the new build instead of copying old ones.
- Write down which php.ini the web server uses and keep the CLI one in step.
- Check the extension list with php -m after each change before restarting anything else.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Apache returns 403 when a URL contains %3F
a request like /page%3Fname=test is refused while /page?name=test works
Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.
2 causes, each with a fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fix