gpt4 book ai didi

symfony - 为什么 Composer 更新需要访问数据库

转载 作者:行者123 更新时间:2023-12-05 01:01:55 27 4
gpt4 key购买 nike

我正在使用 Symfony 2.8 并在启动一个简单的 composer update 命令时遇到了一些问题。

此错误出现在我的开发环境中。我正在使用 vagrant 虚拟机。这是错误:

[Doctrine\DBAL\Exception\ConnectionException]                              
An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused



[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] Connection refused



[PDOException]
SQLSTATE[HY000] [2002] Connection refused


Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

当然,当我在主机上启动命令时会发生这种情况。 PHP 无法连接到数据库,因为我的主机没有。所以这是一种正常的行为。

当我 ssh 进入我的虚拟机时,该命令运行良好。

所以我可以在这里停下来,从我的 VM 更新我的依赖项。

但是,我不希望 composer update 访问我的数据库,我不明白它为什么需要它。

我应该去哪里寻找或者我可以给你什么信息来帮助我解决我的问题?

编辑:这是我的 composer.json 文件:

{
"name": "root/blog",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/",
"SymfonyStandard\\": "app/SymfonyStandard/"
}
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"jms/serializer": "^1.1",
"gedmo/doctrine-extensions": "dev-master",
"friendsofsymfony/user-bundle": "~2.0@dev",
"setasign/fpdf": "^1.8",
"picqer/php-barcode-generator": "^0.2.0",
"oneup/flysystem-bundle": "^1.3",
"itbz/fpdf": "^1.7",
"milon/barcode": "^5.2"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
}

最佳答案

从 Doctrine 2.5 开始,Dctrine\DBAL\Connection::detectDatabasePlatform() 被许多命令调用,并将发出对数据库的调用(在此处发出:https://github.com/doctrine/dbal/issues/990)。

解决方法是在 Doctrine 配置中设置 DB 版本:

doctrine:
dbal:
default_connection: default
connections:
default:
server_version: 5.6

关于symfony - 为什么 Composer 更新需要访问数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38461393/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com