'PHP Startup: Unable to load dynamic library, when running unit tests

when I try to run my unit tests, I get this error

PHP Warning: PHP Startup: Unable to load dynamic library 'bz2' (tried: \xampp\php\ext\bz2 (The specified module could not be found.), \xampp\php\ext\php_bz2.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: \xampp\php\ext\curl (The specified module could not be found.), \xampp\php\ext\php_curl.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'fileinfo' (tried: \xampp\php\ext\fileinfo (The specified module could not be found.), \xampp\php\ext\php_fileinfo.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'gd2' (tried: \xampp\php\ext\gd2 (The specified module could not be found.), \xampp\php\ext\php_gd2.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'gettext' (tried: \xampp\php\ext\gettext (The specified module could not be found.), \xampp\php\ext\php_gettext.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring' (tried: \xampp\php\ext\mbstring (The specified module could not be found.), \xampp\php\ext\php_mbstring.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'exif' (tried: \xampp\php\ext\exif (The specified module could not be found.), \xampp\php\ext\php_exif.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: \xampp\php\ext\mysqli (The specified module could not be found.), \xampp\php\ext\php_mysqli.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: \xampp\php\ext\pdo_mysql (The specified module could not be found.), \xampp\php\ext\php_pdo_mysql.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: \xampp\php\ext\pdo_sqlite (The specified module could not be found.), \xampp\php\ext\php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'php_openssl.dll' (tried: \xampp\php\ext\php_openssl.dll (The specified module could not be found.), \xampp\php\ext\php_php_openssl.dll.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'php_ftp.dll' (tried: \xampp\php\ext\php_ftp.dll (The specified module could not be found.), \xampp\php\ext\php_php_ftp.dll.dll (The specified module could not be found.)) in Unknown on line 0 PHP Warning: Cannot open '\xampp\php\extras\browscap.ini' for reading in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'bz2' (tried: \xampp\php\ext\bz2 (The specified module could not be found.), \xampp\php\ext\php_bz2.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: \xampp\php\ext\curl (The specified module could not be found.), \xampp\php\ext\php_curl.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'fileinfo' (tried: \xampp\php\ext\fileinfo (The specified module could not be found.), \xampp\php\ext\php_fileinfo.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'gd2' (tried: \xampp\php\ext\gd2 (The specified module could not be found.), \xampp\php\ext\php_gd2.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'gettext' (tried: \xampp\php\ext\gettext (The specified module could not be found.), \xampp\php\ext\php_gettext.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'mbstring' (tried: \xampp\php\ext\mbstring (The specified module could not be found.), \xampp\php\ext\php_mbstring.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'exif' (tried: \xampp\php\ext\exif (The specified module could not be found.), \xampp\php\ext\php_exif.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: \xampp\php\ext\mysqli (The specified module could not be found.), \xampp\php\ext\php_mysqli.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: \xampp\php\ext\pdo_mysql (The specified module could not be found.), \xampp\php\ext\php_pdo_mysql.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: \xampp\php\ext\pdo_sqlite (The specified module could not be found.), \xampp\php\ext\php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_openssl.dll' (tried: \xampp\php\ext\php_openssl.dll (The specified module could not be found.), \xampp\php\ext\php_php_openssl.dll.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_ftp.dll' (tried: \xampp\php\ext\php_ftp.dll (The specified module could not be found.), \xampp\php\ext\php_php_ftp.dll.dll (The specified module could not be found.)) in Unknown on line 0

Could somebody help me ? Thanks. Running in PHPstorm, Win 10



Solution 1:[1]

You may need to edit your php.ini file and restart the server. Add absolute paths in php.ini configuration. It worked for xampp server in my windows 8.1 machine.
example:
extension_dir="\xampp\php\ext" to extension_dir="C:\xampp\php\ext"
Reference: How to fix PHP Warning: PHP Startup: Unable to load dynamic library 'ext\\php_curl.dll'?

Solution 2:[2]

You are missing the b2z module for php. Which is normally included in the php package for windows

I would suggest reinstalling php or manually moving the package from the download to the correct folder or switching to a vagrant environment.

Download:

https://windows.php.net/download/

In the folder ext/bz2

Move these folder contents over to the according folder.

Solution 3:[3]

I had faced the same problem after updating my php version from 7.0 to the latest version which is 8.1.3 as for now , the solution I used was :-

Just comment the extension in the php.ini found in (C:\xampp\php\php.ini) extension=gd2

Note: comment by prefixing semicolon at the start

Solution 4:[4]

Just comment out ;extension=pdo_sqlite in php.ini if you don't need it. It was enabled by default in my configuration and the error message is gone.

Solution 5:[5]

I have fought with this for the last 12 hours on my Windows 10 box. For anyone having the same trouble I am having, you need to edit the php.ini to call out the full name of the DLL file. I had to change pdo_sqlite to php_pdo_sqlite.dll and sqlite3 to php_sqlite3.dll.

Solution 6:[6]

after adding php ext dir in php.ini, i also needed to add php dir to windows path (environment variables)

Solution 7:[7]

In your php.ini file, find text=> extension=gd2 and make it ;extension=gd2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Kerel
Solution 3 7137 BUKENYA HUZAIFA
Solution 4 Tadej
Solution 5 Jason Greb
Solution 6 Maloupi
Solution 7 Riaz Bappy