Nette Tester:MySQLi无法正常工作

Normally, in apache via mod php it works perfectly fine, but if I try function_exists('mysqli_init'), function does not exist.

Other errors shown:

Call to undefined function mysqli_connect() Class 'MySQLi' not found in <file>

Why MySQLi isn't working and how to fix it? Thanks!

Command used to run test:

vendor/bin/tester -c /etc/php5/apache2 -p php

Try running ./vendor/bin/tester -c /etc/php5/apache2 -p php --info to see which php.ini file and PHP extensions are loaded.

Most-likely the you are going to find out that the MySQLi extension is not loaded because the /etc/php5/apache2/php.ini does not contain the necessary option.

The correct solution is to create specific php.ini for your project with necessary extensions.

See also official documentation:

The Tester runs PHP processes with -n option, so no php.ini is loaded (not even that from /etc/php/conf.d/*.ini in UNIX)

With tester -c parameter, you need to provide path to php.ini file, not folder containing it.

Also tester resets php environment for repeatable result. It is better idea provide own php.ini which only defines needed extesions:

[PHP}
extension=mysqli.so