Laravel 5.5“未找到‘PDO’类”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48541481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:19:41  来源:igfitidea点击:

Laravel 5.5 "Class 'PDO' not found"

laravellaravel-5pdo

提问by marlonpd

Here is the actual error when I open the site

这是我打开网站时的实际错误

enter image description here

在此处输入图片说明

Actually, I have successfully run php artisan migrate:refresh, and there is no error.

实际上,我已经成功运行了php artisan migrate:refresh,并且没有错误。

Already tried the following command.

已经尝试了以下命令。

php artisan cache:clear
php artisan config:clear

composer install
composer clearcache
composer dump-autoload
php artisan clear-compiled

I also checked if pdo is installed, thru php -mand its already installed

我还检查了是否安装了 pdo,通过php -m它已经安装

enter image description here

在此处输入图片说明

I'm using CentOS.

我正在使用 CentOS。

回答by Tudor

What is most likely happening here is that the PDO module is enabled in the php-cli config (hence it works from command line), but is not enabled on the web server configuration file.

这里最有可能发生的是 PDO 模块在 php-cli 配置中启用(因此它可以从命令行工作),但未在 Web 服务器配置文件中启用。

回答by Veerendra

I am adding all possible options which can solve the issue

我正在添加可以解决问题的所有可能选项

Add use PDO; after your namespace or just before your class or at the top of your PHP file

As you are using centOS try the below commands

当您使用 centOS 时,请尝试以下命令

yum install php-pdo
yum install php-pdo_mysql

service httpd restart

If still its not solved check the php.ini file path to see which is being loaded in the phpinfo() output.

如果仍未解决,请检查 php.ini 文件路径以查看正在 phpinfo() 输出中加载的内容。

Sometimes there are two different PHP versions installed on a machine, one for CLI and one for the web server.

有时,一台机器上安装了两种不同的 PHP 版本,一种用于 CLI,一种用于 Web 服务器。

回答by Gustavo Gon?alves

Restart your apache, nginx, php-fpm

重启你的 apache、nginx、php-fpm