2016-06-15 6 views
2

私はSwiftmailerで電子メールを送信するためにStandalone Twigを使用しようとしています。私はinstructionsの "With Swiftmailer/Twig"セクションに従っています。SymfonyなしのTwig Swiftmailer

これは私のコードです:

require_once('/var/www/folder/includes/vendor/autoload.php'); 

$loader = new Twig_Loader_Filesystem(array('/var/www/templates/utilities/test')); 
$twig = new Twig_Environment($loader, array(
    'cache' => '/var/www/templates/cached', 
    'auto_reload' => true, // set to false to improve performance (Note: You have to clear the cache manually whenever a template is changed) 
    'debug' => true, 
    'use_strict_variables' => false, 
)); 
$twig->addExtension(new Twig_Extension_Debug()); 



$swiftMailerTemplateHelper = new \WMC\SwiftmailerTwigBundle\TwigSwiftHelper($twig, '/var/www/templates/utilities/test'); 
// I'm not exactly sure what the value for the second parameter is supposed to be. 
//The instructions referenced just list a variable called $web_directory. 
//I'm assuming they just mean a path to where the templates are stored. 

echo "hello world"; 

これは私が取得していますエラーです:

PHP Fatal error: Class 'WMC\SwiftmailerTwigBundle\TwigSwiftHelper' not found in /var/www/apps_mymea/utilities/test/email.php on line 16

答えて

1

参照ドキュメントの名前空間は正しくありません。

正しい構文は次のとおりです。

$swiftMailerTemplateHelper = new \WMC\SwiftmailerTwigBundle\Mailer\TwigSwiftHelper($twig, '/var/www/templates/utilities/test'); 
//It was missing the \Mailer\ in the class path. 
関連する問題