Symfony fos:user:create through error "could not find driver", (Xampp with multiple verison of PHP) [英] Symfony fos:user:create through error "could not find driver", (Xampp with multiple verison of PHP)

查看:25
本文介绍了Symfony fos:user:create through error "could not find driver", (Xampp with multiple verison of PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 简介:

我在一个使用 PHPStorm 的 Symfony 项目中.我正在尝试在 DB (xampp MySQL) 上创建一个 fos 用户.

I am in a Symfony Project with PHPStorm. I'm trying to create a fos user on DB (xampp MySQL).

Symfony CLI 版本 v4.21.6作曲家版本 1.10.19

Symfony CLI version v4.21.6 Composer version 1.10.19

C:\Program Files\Symfony\name_projectFolder>php -v
PHP 8.0.0 (cli)

C:\Program Files\Symfony\name_projectFolder>symfony php -v
PHP 7.4.14 (cli)

使用第一个命令,我们看到默认使用的实际 php 版本 (8.0.0),但我的项目不支持它,所以我安装了另一个(在 xampp 文件夹中使用正确的程序)并告诉项目使用此新版本 (7.4.14) 而不是默认版本.

With the first command we see the actual php version (8.0.0) that is used by default, but my project doesn't support it, so i installed another one (on xampp folder with the correct procedure) and told to the project to use this new version (7.4.14) instead of the default one.

设置项目应该使用哪个 php 版本:

TO SET which php version the project should use:

C:\Program Files\Symfony\name_projectFolder>echo 7.4 > .php-version

查看我们拥有的 PHP 版本列表:

TO SEE the list of PHP versions that we have:

C:\Program Files\Symfony\name_projectFolder>symfony local:php:list

左侧突出显示的数字是项目使用的实际版本.右边的星号表示默认系统PHP版本.

The highlighted number on the left is the actual version that the project is using. The asterisk on the right indicates the default system PHP version.

(信息:如果你想使用一个普通的命令,你需要指定它应该引用哪个 PHP 版本,以便运行它.为此,只需在普通命令之前添加symfony"因为它将使用项目设置而不是系统设置.)

(INFO: If you want to use a normal command you need to specify which PHP version it should refer to, in order to run it. To do so just add before the normal command the "symfony" word because it will use the project settings and not the system ones.)

  • 开始创建 fos 用户的过程:
  • START with the procedure to CREATE the fos user:

(正如我们之前所说,我们使用symfony"这个词来告诉"使用 7.4 PHP 版本的命令,请记住,通常您不会这样做)

(as we said before, we use the word "symfony" to "tell" to the command to use the 7.4 PHP version, keep in mind that normally you don't to this)

C:\Program Files\Symfony\name_projectFolder>symfony php bin\console fos:user:create

您将收到此错误:

简而言之驱动程序发生异常:找不到驱动程序"

推荐答案

解决方案

因为你有两个 PHP 版本,所以在新版本中你需要启用 pdo_mysql 扩展,而通常没有.

Because you have two PHP versions, in the new one you need to enable the pdo_mysql extension that normaly is not.

在 XAMPP 控制器中停止 Apache 服务器.

STOP the Apache Server in the XAMPP controller.

只需进入文件夹 C:\xampp\php7_4 并打开文件 php.ini

just go in the folder C:\xampp\php7_4 and open the file php.ini

搜索 (CTRL+F) pdo_mysql 并取消注释/删除;"

search (CTRL+F) for pdo_mysql and uncomment/remove the ";"

BEFORE ;extension=pdo_mysql

AFTER extension=pdo_mysql

保存更改

启动 Apache 服务器并重新运行 symfony php bin\console fos:user:create 命令,它会工作!!

START the Apache Server and re-run the symfony php bin\console fos:user:create command and it will work !!

这篇关于Symfony fos:user:create through error "could not find driver", (Xampp with multiple verison of PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆