gpt4 book ai didi

composer-php - 在 database_driver 上获取 [Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException] 错误

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

当我跑 php -d memory_limit=2G ../composer/composer.phar 安装 ,我收到关于不存在的参数“database_driver”参数的错误。但是,如果我从我的 parameters.yml 和 parameters.yml.dist 文件中删除所有引用,那么我的网络应用程序将失败:

ParameterNotFoundException in ParameterBag.php line 84:
You have requested a non-existent parameter "database_driver".
Did you mean one of these: "database_name", "database_user"?

所以我很清楚我需要这个参数。

我在 中定义了“database_driver”参数.yml 参数.yml.dist 文件,它存在于我的 中config.yml 文件。

**我需要更改什么才能成功运行“composer install”命令?

注意:我还看到“composer install”命令的以下输出表明我的 composer.lock 文件已过期并运行“composer update”命令,但是当我这样做时,它因内存不足而失败错误,这是没有意义的,因为我在服务器上有 3 场内存和超过 28 场可用磁盘空间!如果可能,我想先尝试解决“database_driver”问题**

这是 的输出“堆肥器安装”命令,上面:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file

Warning: The lock file is not up to date with the latest changes in
composer.json. You may be getting outdated dependencies. Run update to
update them.

Nothing to install or update
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database_driver". Did you
mean one of these: "database_name", "database_user"?

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
handling the symfony-scripts event terminated with an exception

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database_driver". Did you
mean one of these: "database_name", "database_user"?

这是我的 参数.yml.dist 文件:
# This file is a "template" of what your parameters.yml file should look like
# Set parameters here that may be different on each deployment target of the app,
# e.g. development, staging, production.
# http://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
database_name: ##########
database_user: ##########
database_password: ##########

# You should uncomment this if you want use pdo_sqlite
database_path: "%kernel.root_dir%/data.db3"

mailer_transport: smtp
mailer_host: smtp.sendgrid.net
mailer_user: #############
mailer_password: #############

locale: en

# A secret key that's used to generate certain security-related tokens
secret: ############################

这是我的 参数.yml 文件:
# This file is auto-generated during the composer install

parameters:
database_driver: pdo_mysql
database_server_version: 15.1
database_host: 127.0.0.1
database_port: 3306
database_name: ##########
database_user: ##########
database_password: ##########
database_charset: UTF8

# You should uncomment this if you want use pdo_sqlite
database_path: "%kernel.root_dir%/data.db3"

mailer_transport: smtp
mailer_host: smtp.sendgrid.net
mailer_user: ##########
mailer_password: ##########

locale: en

# A secret key that's used to generate certain security-related tokens
secret: #######################

这是我的 config.yml 文件:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }

# Put parameters here that don't need to change on each machine where the
# app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration

parameters:
locale: en

framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true

# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"

# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
server_version: "%database_server_version%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: "%database_charset%"

# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"

orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true

# Swiftmailer Configuration
##swiftmailer:
## transport: "%mailer_transport%"
## host: "%mailer_host%"
## username: "%mailer_user%"
## password: "%mailer_password%"
## port : “%mailer_port%”
## encryption: ~
## spool: { type: memory }

这是我的 config_dev.yml 文件:
imports:
- { resource: config.yml }

framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }

web_profiler:
toolbar: true
intercept_redirects: true

monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info

swiftmailer:
# delivery_address: ###@####.###

最后,这是我的 的内容composer.json 文件:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" },
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"require": {
"php": ">=5.6.0",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"google/recaptcha": "~1.1",
"sendgrid/sendgrid": "~5.5"
},
"require-dev": {
"sensio/generator-bundle": "~3.0",
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"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::prepareDeploymentTarget"
],
"post-install-cmd": [
"@symfony-scripts"
],
"post-update-cmd": [
"@symfony-scripts"
]
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.6.0"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.8-dev"
}
}
}

感谢您对这个问题的任何帮助。

最佳答案

@霍华德布朗

我通过添加 解决了这个问题数据库驱动程序 中的参数参数.yml 以及 参数.dist

我想每当我们更新 参数.yml (使用应该在 prod 服务器上的配置也很好),您也必须更新文件参数 .yml.dist 。

以下是 的示例结构参数.yml.dist 文件

例如:

parameters:
database_host: 127.0.0.1
database_port: *****
database_name: symfony
database_user: root
database_password: *****
database_driver: mysql

欲了解更多信息
  • Stackoverflow
  • Github issue
  • 关于composer-php - 在 database_driver 上获取 [Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException] 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44793412/

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