Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bhojkamal's avatar

Class "PDO" not found for laravel 9 application

Hello, I am hosting my website on cloud share hosting from cpanel. And I am getting Class PDO not found for laravel 9 website.

I think that this is due to the php version conflict on cpanel. My current version on cpanel is 7.4.28, and for my laravel 9 website I chose PHP 8.0 (ea-php80). It throws Class 'config' not found. When I changed PHP 8.0 (alt-php80). The laravel website is working until the database does not need to connect. When need to connect to database, It throws error again Class "PDO" not found. So, I think, it could not use PDO extension from current php version 7.4.28 and for this specific website is PHP 8.0 (alt-php80). So It could not connect to db and get data or login to website.

However, when I changed the current to PHP 8.0 on cpanel. It is working, without any issue for laravel 8 and 9 projects and some cI3 website too. but I've one project on CI3. It didn't worked at all. And It is important application and I cannot upgrade it now.

I think the solution would be for current version PHP 7.4.28 for cpanel. and choosing PHP 8.0 (alt-php80) for laravel 9, It should make to get PDO extension . If someone idea about this situation in cPanel, please share here.

Kind Regards.

0 likes
5 replies
bobbybouwmann's avatar

It sounds to me that you use an incomplete PHP version. To use PDO, you need to have the php-pdo extension enabled. It seels that alt-php80 doesn't have this enabled by default. Is there any other PHP version you can pick?

Also, ea-php80 and alt-php80 sounds like really old version of early PHP 8. I would contact your server provider to ask them to update to the latest PHP 8.0 so you can have it running normally

1 like
bhojkamal's avatar

@bobbybouwmann This is the latest php version I can picked which is minimum require for laravel 9. Other php version are php 5.6 to php 7.4. all has alt-php56, ea-php56 - alt-php74 ea-php74 and ea/alt php 8.0

bobbybouwmann's avatar

@bhojkamal As I said, you should contact your server provider and ask for more options. These are all old versions and there is no good reason not to get the right version here.

1 like
bhojkamal's avatar

Somehow it has worked now with PHP 8.0 (ea-php80) for new laravel 9 project.

usmanlatif306's avatar

I know I am replying too late but was encountered same issue and after searching I found following solution.

Add the following line to your .htaccess file in public folder

<FilesMatch ".(?:html|php)$">
SetHandler application/x-lsphpXX
</FilesMatch>

Where XX is the PHP version you wish to set. It can be 52, 53, 54, 55, 56, 70, 71,72, 73, 74, 80 or 81.

NOTE:

When a different PHP version is set for the addon domain, there are no PHP extensions enabled by default. To make a website work correctly, you will need to upload a php.ini file to the folder of the addon domain. You need to download the php.ini file for different PHP versions from the end of this comment. Do not forget to rename the file to php.ini once it is uploaded to the hosting account.

Upload php.ini file in both root and public folders

I follow this help guide https://www.namecheap.com/support/knowledgebase/article.aspx/9417/2219/how-to-change-php-version-and-update-php-extensions-on-shared-servers/

Please or to participate in this conversation.