user3715053
user3715053

Reputation: 41

php cli not working, pdo not found

I run this command to debug why php cli not working:

php -n MYPHPFILE.php 

And get this:

Fatal error: Class 'PDO' not found in example-file.php on line 59

I have checked PDO extension and its already correct installed. Im running nginx, php5 fpm server.

Any idea what is wrong?

Upvotes: 2

Views: 793

Answers (1)

Joe Watkins
Joe Watkins

Reputation: 17148

The -n switch means (quoted from php --help):

No php.ini file will be used

When PHP is built, it is usually configured with the option --with-config-file-scan-dir=target. This causes PHP to scan target upon startup for additional ini files, target might be something like /etc/php.d. This is usually the mechanism by which individual extensions are loaded.

The help text omits to mention that -n also stops target being scanned, what it will soon say is:

No configuration (ini) files will be used

This results in the configuration line that loads PDO (extension=pdo.so) not being used, either because it is in php.ini or because it is in another ini file inside the scan directory.

Remove the -n switch.

Upvotes: 4

Related Questions