PHP Fatal error: Class 'PDO' not found usi

2019-02-15 13:26发布

After one hour tring to solve this problem I failed ): my error message is :

Generating autoload files
PHP Fatal error:  Class 'PDO' not found in /usr/share/nginx/html/laravel/app/config/database.php on line 16
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'PDO' not found","file":"\/usr\/share\/nginx\/html\/laravel\/app\/config\/database.php","line":16}}Script php artisan clear-compiled handling the post-update-cmd event returned with an error



  [RuntimeException]                                                                                                    
  Error Output: PHP Fatal error:  Class 'PDO' not found in /usr/share/nginx/html/laravel/app/config/database.php on li  
  ne 16                                                                                                                 




update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]

I am using linux centos 6.4 php 5.5.3 and laravel 4.

Could you help me thanks very much.

4条回答
乱世女痞
2楼-- · 2019-02-15 13:41

Another issue is namespacing so use \PDO and not just PDO

查看更多
不美不萌又怎样
3楼-- · 2019-02-15 13:46

Here's my answer for Laravel 5 on CentOS 7 using NGINX+PHP-FPM.

CentOS 7 only PHP 5.4 is supported (at time of writing). You can install PHP versions 5.5 or 5.6 (and perhaps others) using the WebTatic repo. In the end, I decided to launch a clean CentOS 7 instance, here's my recipe:

  1. Minimal ISO install of CentOS 7 + yum install epel-release (if not using the Minimal install, try to yum remove php and other php-* packages).

  2. Install the WebTatic repo: sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

  3. Install minimum set of PHP 5.6 packages for Laravel 5: sudo yum install php56w php56w-opcache php56w-common php56w-pdo php56w-mbstring

  4. For NGINX PHP support, I use PHP-FPM: sudo yum install php56w-fpm

For any other PHP packages that are required, assuming the WebTatic repo is installed, substitute php- with php56w- in the package name.

查看更多
趁早两清
4楼-- · 2019-02-15 13:49

You'll need to:

  1. Install PDO support.
  2. Enable PDO in your PHP configuration. This can be done by adding the following:

extension=pdo.so

extension=pdo_mysql.so

to your php.ini file.

查看更多
叼着烟拽天下
5楼-- · 2019-02-15 13:52

You can check if PDO is supported and which drivers are available using this script:

<?php
if (defined('PDO::ATTR_DRIVER_NAME')) {
    print_r(PDO::getAvailableDrivers());
} else {
    echo 'PDO unavailable';
}

If it says "PDO unavailable" you have to install and enable it.

For installing PDO on centos type:

yum install php-pdo
查看更多
登录 后发表回答