On my Windows 7 machine, with PHP v5.6.7 and MySQL v5.6.23, and using PHPStorm 8, I am attempting to instantiate a mysqli object. When I try, I get:
Fatal error: Class 'mysqli' not found in...
I have also run this test, suggested here:
if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
echo 'no mysqli :(';
} else {
echo 'we gots it';
}
The output is:
no mysqli :(
I read here that this problem is sometimes caused when it looks for the mysqli class within a namespace. I changed my code to correct this, but the issue persists
$mysqli = new \mysqli($host, $userName, $password, $database);
I read that this problem is sometimes caused when the mysqli extension is not enabled. However, I am using PHP version 5.6.7, and the mysqli extension is enabled by default on versions 5.3 and newer (according to here).
Just to be sure, I have verified that php.ini-development
and php.ini-production
have extension_dir = "C:/PHP/php-5.6.7/ext"
and have the semi-colon removed from the lines:
extension=php_mysql.dll
extension=php_mysqli.dll
[Additional information] I found a test to run and according to phpinfo() it is not loading a configuration file:
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File (none)
Scan this dir for additional .ini files (none)
Additional .ini files parsed (none)
For some reason, the PHPStorm web server is not looking for php.ini in the right place?
I have this setting in the "Interpreter options" per this:
--php-ini C:\PHP\php-5.6.7\php.ini
I have verified that this is the correct path.
scrowler and Michael Bush pointed out the answer in comments above. I thought I'd create an answer for it for the benefit of someone viewing the thread. Thanks, scrowler and Michael Bush.
The php.ini-development
and php.ini-production
files are templates. In order to have effect, one of them needs to be copied and renamed php.ini
.
Have you added the PHP installation directory to you environment path
Also check this entry in your php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "c:/php/ext"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With