PHP loads the same extension twice at start-up
PHP Warning: Module already loaded in Unknown on line 0Short answer
PHP read two ini lines that load the same extension, so it warned at start-up (hence 'Unknown on line 0'). Run php --ini to see every ini file PHP parsed, search them for the extension name, and keep one line. The usual double is php.ini plus a file in the scan directory.
Fix it fast
1Find out which cause you have
Ask PHP which ini files it parsed, then search all of them for the extension named in the warning.
php --ini php --ini | grep -oE '/[^ ,]+\.ini' | xargs grep -n "intl"2Match what you see, then jump to its fix
- 1
php --ini lists the main php.ini and, under 'Additional .ini files parsed', a second file that also has the same extension= line.php.ini and a scanned ini file both load the extensionFix - 2
The warning appears only in one environment (a shell, a container, a service) that sets PHP_INI_SCAN_DIR, and php --ini lists the scan directory more than once or lists two copies of the same ini file.The same directory is scanned twice through PHP_INI_SCAN_DIRFix
- 1
What does the error look like?
PHP Warning: Module already loaded in Unknown on line 0
Cause 1 of 2
php.ini and a scanned ini file both load the extension
1Check
After the main file, PHP scans the configured directory and loads every .ini file in it in alphabetical order. An extension line in php.ini and another in one of those files loads it twice.
php --ini
php -r "var_dump(php_ini_scanned_files());"2Fix
Keep one of the two lines. Comment out the line in the file you do not want to keep, with a semicolon at the start.
; php.ini
;extension=intl3Verify
Run PHP again. The warning is gone and the extension is still loaded.
php -v
php -m | grep -i intlConfirmed by php.net
Cause 2 of 2
The same directory is scanned twice through PHP_INI_SCAN_DIR
1Check
PHP_INI_SCAN_DIR replaces the compile-time scan directory. A blank entry in it makes PHP scan the compile-time directory as well, so a folder can be read twice, or two folders can each hold a file that loads the extension.
echo "$PHP_INI_SCAN_DIR"
php --ini2Fix
Set PHP_INI_SCAN_DIR to the folders you really want, without a blank entry (no leading or trailing colon) and without the folder listed twice. Then remove duplicate ini files.
export PHP_INI_SCAN_DIR=/usr/local/etc/php.d3Verify
Run php --ini again and check that every ini file is listed once.
php --iniConfirmed by php.net
How do I stop it coming back?
- Add each extension in exactly one file, and let your package manager own the scan directory.
- After installing a PHP build or a panel, run php --ini and read the list once.
- Keep CLI and FPM ini files in mind: they can differ, so check the one that prints the warning.
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
PHP prints 'Unable to load dynamic library' every time it starts
Warning: PHP Startup: Unable to load dynamic library 'php_curl.dll'
PHP read an extension line in php.ini and could not open the file.
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 fixBack end
CodeIgniter 4 cannot write its cache files
CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/
CodeIgniter 4's file cache needs a cache directory that the web server can really write to.
2 causes, each with a fixBack end
CodeIgniter 3 loads the model but the property is undefined
The model name you are loading is the name of a resource that is already being used: user
CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.
2 causes, each with a fix