laravel PDO::ATTR_STATEMENT_CLASS 需要格式 array(classname, array(ctor_args)); 类名必须是指定现有类的字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48967363/
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:26:35  来源:igfitidea点击:

laravel PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class

phplaravel

提问by Mohamed Magdy

i was working on a laravel project then i installed a new package using composer and i found this error

我正在处理一个 Laravel 项目,然后我使用 composer 安装了一个新包,我发现了这个错误

PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class

PDO::ATTR_STATEMENT_CLASS 需要格式 array(classname, array(ctor_args)); 类名必须是指定现有类的字符串

i tried to :-

我试过了 :-

  1. revert to previous commit on git
  2. remove vendor folder and composer.lock and reinstall all with no results
  1. 恢复到以前的 git 提交
  2. 删除供应商文件夹和 composer.lock 并重新安装所有没有结果

enter image description here

在此处输入图片说明

回答by Jose Gratereaux

Had the same problem here. Downgrading to composer require doctrine/dbal=2.6.3did the trick so far.

这里有同样的问题。到目前为止,降级到作曲家需要学说/dbal=2.6.3就成功了。

回答by S.Sasaki

I had same problem. After downgrading doctrine/dbal 2.7to 2.6.*, the problem was resolved.

我有同样的问题。降级doctrine/dbal 2.72.6.*,问题解决。

回答by scandar

i had the same problem after reinstalling a new OS (ubuntu 16.04), solved by running composer updatethen composer dump-autoload.

重新安装新操作系统(ubuntu 16.04)后,我遇到了同样的问题,通过运行composer updatethen解决了composer dump-autoload

seems to be a problem with caching in composer

似乎是 Composer 中的缓存问题

回答by fredrib

I had the same problem and it turn out to be a configuration on Nginx, which was still pointing to the php7.0-fpm after I've upgraded to php 7.2.

我遇到了同样的问题,结果是 Nginx 上的一个配置,在我升级到 php 7.2 后仍然指向 php7.0-fpm。

I've just fix that on /etc/nginx/sites-available/default

我刚刚解决了这个问题 /etc/nginx/sites-available/default

回答by TriMinh

Edit composer.json: "doctrine/dbal": "2.8." to "doctrine/dbal": "2.4." and run composer update will resolve problems.

编辑 composer.json: "doctrine/dbal": "2.8. " 到 "doctrine/dbal": "2.4." 并运行 composer update 将解决问题。

回答by Lordwhizy

I found this question because i had a similar problem.

我发现这个问题是因为我有类似的问题。

I upgraded from PHP 7.0 to PHP 7.2 and the problem started.

我从 PHP 7.0 升级到 PHP 7.2,问题开始了。

I knew it had to do with the server not the laravel application.

我知道这与服务器有关,而不是 Laravel 应用程序。

After search with no luck. I simply restarted my httpd.service and viola! It worked.

搜索后没有运气。我只是重新启动了我的 httpd.service 和 viola!有效。

I guess this because i didn't restart the http server after the upgrade from PHP 7.0 to 7.2.

我猜这是因为从 PHP 7.0 升级到 7.2 后我没有重新启动 http 服务器。

So just reboot the server or restart the http service might get this fixed.

因此,只需重新启动服务器或重新启动 http 服务即可解决此问题。

回答by ruwan800

I was able to fix this issue by removing php7.0-commonpackage when I've installed both php7.0 and php7.2.

php7.0-common当我同时安装 php7.0 和 php7.2 时,我能够通过删除包来解决这个问题。

Initially, command-line was using php7.2 (php -v) but when I checked phpinfoin the browser it was using php7.0. That might have caused the problem for me.

最初,命令行使用的是 php7.2 ( php -v),但是当我phpinfo在浏览器中查看时,它使用的是 php7.0。这可能给我带来了问题。

回答by Demaestro

Try updating your PHP version to 7 or 7.1

尝试将您的 PHP 版本更新到 7 或 7.1