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

bhojkamal's avatar

Class "config" does not exist in /vendor/laravel/framework/src/Illuminate/Container/Container.php:877 Laravel 9

Hello, I am trying to deploying the laravel 9 application from the cpanel. After setup is completed, when I hit the website, I got this error

Fatal error: Uncaught ReflectionException: Class "config" does not exist in /vendor/laravel/framework/src/Illuminate/Container/Container.php:877 Stack trace: #0

How to solve this error?

Thank you

0 likes
15 replies
okusax's avatar

hi @bhojkamal are you using a vps or a shared host?

do you have any way to run a shell command on the server?

I think composer install has not been executed for your applicarion yet

bhojkamal's avatar

@okusax I am using shared host - cloud hosting. But I have terminal on cpanel. I can run some command like php artisan optimize

okusax's avatar

@bhojkamal setting laravel in a shared host is not always possible due to some times you are unable to install the required dependencies in the host. Are you able to run the following commands on the host?

composer install --no-dev
composer dump-autoload
MohamedTammam's avatar

Delete your vendor folder and run.

composer install
composer dump-autoload
php artisan cache:clear
php artisan config:clear
bhojkamal's avatar

@MohamedTammam Yes. I also already added everything from local when moving to server. I have multiple domains, and my others domains require php 7.4. Cannot be run on 8. My only new projects will be on laravel 9, which requires php 8.0. I choose php 8.0 for this domain.

bhojkamal's avatar

I found 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 throw error again Class "PDO" not found. So, it could not use PDO extension for 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 PHP 8.0 to 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.

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.

okusax's avatar

@bhojkamal I don't know if you would be able to perform any installation from inside cpanel (ssh and sudo permissions to install the missing php packages if not installed yet) Your hosting should enable your account to do so.

Maybe you could try ask your hosting provider if they can enable the PDO package for php7.4.28 in your account.

1 like
bhojkamal's avatar
bhojkamal
OP
Best Answer
Level 1

@nanotanitim Yes, it is due to server configuration. contact your host provider. I complained to host provider and it worked after 2-3 week automatically.

1 like

Please or to participate in this conversation.