Search code examples
phppdophp-extension

PDO extension not loading in PHP


So i'm trying to use the PDO module in PHP on a Redhat based distribution (RHEL7) to interact with a database.

In my Php script i have the 'use PDO;' directive, but in the PHP log i get an error : PHP Fatal error: Uncaught Error: Class 'PDO' not found in ...

The extension is uncommented in the php.ini file (extension = pdo.so), i have tried with the relative and the absolute path. I even reinstalled the php-pdo package (yum install), but without success.

I've compared my phpinfo() with a working phpinfo(), and i am missing the PDO section.

I have checked and Apache loads the correct php.ini file

I've passed all my extensions permissions to 755 just to be sure.

I don't get any php warning at startup so i don't know where the problem seems to be.


Solution

  • I found the error : First i started using php in direct command line, and set the env' variable LD_DEBUG=libs:

    ./php -c /path/to/php.ini /path/to/php/file.php
    

    So with that i was able to get the debug on the dynamic loading of my modules and on the php.ini.

    I saw that there was an uncommented line that was blocking the loading of the modules in the INI file, then you have to load the mysql.so module before the pdo_mysql.so and of course restart you apache server.