PHP Unable to load dynamic library ‘\xampp\php\ext\php_bz2.dll’

當我嘗試在Command Prompt上執行 php的指令時..出現以下的錯誤
PHP Warning: PHP Startup: Unable to load dynamic library ‘\xampp\php\ext\php_bz2.dll
PHP Startup: Unable to load dynamic library php_bz2.dll

PHP Warning: PHP Startup: Unable to load dynamic library ‘\xampp\php\ext\php_curl.dll
PHP Startup: Unable to load dynamic library php_curl.dll

還有很多其他的Dynamic Library
PHP unable to load dynamic library

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_bz2.dll

Warning: PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_bz2.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_curl.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_mbstring.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_exif.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_gd2.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_gettext.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_mysql.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_mysqli.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_openssl.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_pdo_mysql.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_pdo_sqlite.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_soap.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_sockets.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_sqlite3.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_xmlrpc.dll

PHP Warning:  PHP Startup: Unable to load dynamic library '\xampp\php\ext\php_xsl.dll

PHP Warning:  Cannot open '\xampp\php\extras\browscap.ini' for reading in Unknown on line 0

之後去查看了 php/ext 資料來..
[由于我是使用 xampp 的關係..我的xampp 資料夾是儲存在d:\
所以我的 xampp path 是這樣的 D:\xampp\php\ext\]

發現上面說明’Unable to load‘ 的 Dynamic Library 都可以在這裡找到
PHP Ext Folder in XAMPP

所以應該不是Library的問題
而是php.ini 內的一些設定問題

做了一會research 之後發現

解決方法十分簡單
只要將預設的 extension_dir 設定變成我們的 absolute path便可以
E.G. D:\xampp\php\ext\

extension_dir = "\xampp\php\ext"

php.ini extension_dir
轉成

extension_dir = "d:\xampp\php\ext"

php.ini extension_dir with absolute path

之後問題便可以解決
PHP command works

Hope you find it useful

Leave a Reply