2017-12-28 2 views
1

symfony 3 프로젝트에 대한 SMTP를 platform.sh에 구성하려고했지만 작동하지 않았습니다.symfony 3 프로젝트에 대해 platform.sh에서 smtp 구성

나는이 문서 [https://docs.platform.sh/administration/web/email.html#sending-e-mail][1].

parameters.yml은 빌드 프로세스 중에 생성되므로 편집 할 수 없습니다. 그래서 paramters.yml.dist를 편집하려고했습니다. 그리고이 코드로 updatet :

mailer_transport: smtp 
mailer_host:  "%env(PLATFORM_SMTP_HOST)%" 
mailer_user:  null 
mailer_password: null 

나는 내가 빌드하는 동안 다음과 같은 오류 메시지가 나타납니다 않는 경우 :

W: [RuntimeException]                
W: An error occurred when executing the "'cache:clear --no-warmup'" command:   
W:                      
W:  [Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]  
W:  You have requested a non-existent parameter "env(platform_smtp_host)". 

그래서 내가 paramters_platform.php을 편집하려고 다음과 같은 코드를 추가 :

$container->setParameter('mailer_host','%env(PLATFORM_SMTP_HOST)%'); 

그런 다음 빌드 프로세스가 작동하지만 내가 웹 사이트로드 다음과 같은 오류 메시지가 얻을 :

ParameterNotFoundException in ParameterBag.php line 84: 
You have requested a non-existent parameter "env(platform_smtp_host)". 
in ParameterBag.php line 84 
at ParameterBag->get('env(platform_smtp_host)') in ParameterBag.php line 200 
at ParameterBag->resolveString('%env(PLATFORM_SMTP_HOST)%', array('mailer_host' => true, 'env(platform_smtp_host)' => true)) in ParameterBag.php line 171 
at ParameterBag->resolveValue('%env(PLATFORM_SMTP_HOST)%', array('mailer_host' => true)) in ParameterBag.php line 200 
at ParameterBag->resolveString('%mailer_host%', array('mailer_host' => true)) in ParameterBag.php line 171 
at ParameterBag->resolveValue('%mailer_host%', array()) in ParameterBag.php line 161 
at ParameterBag->resolveValue(array('transport' => '%mailer_transport%', 'host' => '%mailer_host%', 'username' => '%mailer_user%', 'password' => '%mailer_password%'), array()) in ParameterBag.php line 161 
at ParameterBag->resolveValue(array(array('transport' => '%mailer_transport%', 'host' => '%mailer_host%', 'username' => '%mailer_user%', 'password' => '%mailer_password%'))) in MergeExtensionConfigurationPass.php line 45 
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in MergeExtensionConfigurationPass.php line 39 
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in Compiler.php line 104 
at Compiler->compile(object(ContainerBuilder)) in ContainerBuilder.php line 597 
at ContainerBuilder->compile() in bootstrap.php.cache line 2687 
at Kernel->initializeContainer() in bootstrap.php.cache line 2465 
at Kernel->boot() in bootstrap.php.cache line 2496 
at Kernel->handle(object(Request)) in app_dev.php line 30 

누구든지 SMTP가 plaform.sh에서 작동하도록 관리 했습니까? 아니면 누구든지이 문제를 없애는 방법을 알고 있습니까?

대단히 감사합니다!

답변

2

예전의 Symfony 3x 버전을 사용하고있는 것처럼 보입니다. %env()% 구문은 3.2 버전에서 도입되었습니다. 이 문제를 해결하려면 parameters.php 파일을 구성 디렉토리에 만들고 config.yml으로 가져올 수 있습니다. 에 대한 몇 가지 매개 변수를 설정하려면이 옵션을 사용하여 http://php.net/manual/en/function.getenv.php

+0

: http://symfony.com/doc/3.3/configuration/external_parameters.html 의 GetEnv() : 외부 매개 변수를 설정

:

<?php $container->setParameter('mailer_host', getenv('PLATFORM_SMTP_HOST')); 

일부 기사 :이 파일은 단지 getenv() PHP 함수를 이용하여 필요한 컨테이너 매개 변수를 설정 내부 2.8 프로젝트의 컨테이너이며 항상 잘 작동했습니다. – dlondero