Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将symfony部署到Heroku,通过configvars获取swiftmailer参数_Symfony_Variables_Heroku_Config_Swiftmailer - Fatal编程技术网

将symfony部署到Heroku,通过configvars获取swiftmailer参数

将symfony部署到Heroku,通过configvars获取swiftmailer参数,symfony,variables,heroku,config,swiftmailer,Symfony,Variables,Heroku,Config,Swiftmailer,我已经将我的symfony应用程序部署到Heroku,但我想用Heroku提供的配置变量配置swiftmailer组件。我已经有两个: SYMFONY_环境:产品 CLEARDB_数据库_URL:我的连接字符串 现在我要做的是在config_prod.yml中描述swiftmailer凭据: #config_prod.yml swiftmailer: transport: "%env(mail_transport)%" host: "%env(mail_host)%"

我已经将我的symfony应用程序部署到Heroku,但我想用Heroku提供的配置变量配置swiftmailer组件。我已经有两个:

  • SYMFONY_环境:产品
  • CLEARDB_数据库_URL:我的连接字符串
  • 现在我要做的是在config_prod.yml中描述swiftmailer凭据:

    #config_prod.yml
    
    swiftmailer:
        transport: "%env(mail_transport)%"
        host:      "%env(mail_host)%"
        username:  "%env(mail_user)%"
        password:  "%env(mail_password)%"
        spool:     { type: memory }
    
    一、 然后,在Heroku上设置config_vars,但是在尝试部署应用程序时,我遇到了以下异常

    [Symfony\Component\DependencyInjection\Exception\EnvParameterException]
    Incompatible use of dynamic environment variables "mail_transport" found in parameters.
    
    [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
    Unable to replace alias "swiftmailer.mailer.default.transport.real" with actual definition "%env(mail_transport)%".
    
    [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
    You have requested a non-existent service "%env(mail_transport)%".
    
    Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
    
    如果我在config.yml中硬编码参数,那么部署到Heroku将成功


    我搞砸了什么?Thx提前。

    我不太了解heroku,但我知道如何在symfony config;中获取环境变量。)

    在其他配置文件所在的
    app/config
    内部创建一个名为
    parameters.php的新文件


    我对heroku知之甚少,但我知道如何在symfony config;中获取ENV_VAR;)

    在其他配置文件所在的
    app/config
    内部创建一个名为
    parameters.php的新文件


    您是如何让电子邮件在heroku上运行的?@Baig在config_prod.yml中我使用了以下配置swiftmailer:transport:smtp主机:smtp.sendgrid.net用户名:“%env(sendgrid_username)%”密码:“%env(sendgrid_password)%”端口:587您是如何让电子邮件在heroku上工作的?@Baig在config_prod.yml中我使用了以下配置swiftmailer:传输:smtp主机:smtp.sendgrid.net用户名:“%env(sendgrid_username)%”密码:“%env(sendgrid_password)%”端口:587
    
    imports:
        - { resource: parameters.yml }
        - { resource: parameters.php } <------------