Upgrading from ZF3 to Laminas with PHP 8.1 PDO Exception could not find driver when using \PDO()

I have a number of Zend Framework 3 applications (20) running on the same Apache2.4 server.
These applications were added to the base skeleton Application so they all run under the same doc root.
I’m using Ubuntu-20.04 Server on a Nutanix VM…
Using ZF3 with PHP 7.4 all of the applications work good…
If I update PHP to 8.1 with ZF3 all of the applications are working good…
If I update PHP to 8.1 with Laminas I’m getting PDO Exception, could not find driver errors…
Note: I’m connecting to databases by directly instantiating with new \PDO() …
I went through my PHP configuration and verified that PDO and pdo_mysql, as well as other pdo drivers are all enabled via PHP Info…
Since there is no PHP errors showing; in most cases, in the Apache2 error log I don’t have a good way to troubleshoot the problem… I do see on some pages the PDO Exception which at least points to the idea that the application can not find the driver.
I have been Googling this topic for a couple of days without much luck and I’m wondering if this is a known problem or bug that others have encountered.
Please let me know if there is anything in particular from my configuration that would be needed to help me investigate this problem.

Hi @iwidgit,

Have you tried installing MySQL driver for PHP 8.1? If not give it a try.

sudo apt-get install php8.1-mysql php8.1-xml php8.1-curl php8.1-gd php8.1-intl

I hope it helps. Thnaks!

Thank you for responding…
When I first observed the problem checking to make sure I had the modules you suggested was something I did… I also uninstalled PHP 8.1 and then reinstalled it; making sure the proper extensions were installed. The symptom described with the PDO Exception persisted.

Hello and welcome to our forums! :smiley:

Can you provide the exact text of the exception?

Hi @iwidgit,
Is your MySQL on default port 3306 or something else?
Thanks!

My MySQL Server is on the standard port…

I have switched back to PHP 7.4… on this machine, would need to reinstall PHP 8.1 to try and generate the PDOException.

The error as I recall was simply PDOException could not find driver…
And it references the exact line in the Model file where the error is occurring.
This error was blended in with the page it was supposed to be opening…
There was also a Error Stack near the bottom but this really only points to the error generation code coming from the vendor libraries.
There was no reference to any files like the Model that generates the error.
Perhaps I should try to reinstall PHP 8.1 and see if I can get this working…
It does appear that the most common response to this error is to reinstall all of the driver extensions
and verify they are loaded.

I did a reinstall of PHP 8.1 this morning…
I installed PHP 8.1.6, previously the version was 8.1.5.
Testing I find everything is now working and I can’t say for sure what is different
than before but it is all working now…
Thank You for your help as I might not have tried to reinstall PHP otherwise…

Hi @iwidgit,
Congrats on upgrading your project to the latest version of Laminas and PHP 8.*. That indeed calls for a toast. You’re obliged to do it at your own expense. Thanks!