我正在与Symfony 3.4挣扎并自动化。
他在这里有一个错误消息的范围: Argument 2 passed to AppControllerMainController::contact() must be an instance of Swift_Mailer, null given
这是每个 service 我通过参数的同一条消息。
配置中可能缺少一些东西,但我不知道什么...
有任何线索?
// config/services.yaml
parameters:
google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%'
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
AppController:
resource: '../src/Controller'
public: true
tags: ['controller.service_arguments']
// src/Controller/MainController.php
namespace AppController;
use Exception;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentHttpKernelExceptionNotFoundHttpException;
use SymfonyComponentValidatorValidation;
class MainController extends AbstractController
{
public function contact(
Request $request,
Swift_Mailer $mailer,
Validation $validation,
) { ... }
}
我确实设法解决了我的问题。
我有 sensio bundle frameworkextrabundle sensioframeworkextrabundle 已启用,而且似乎我们似乎无法拥有 sensio/frameio/framework-extra-extra-bundle and strong> symfony/symfony/symfony/flex (或使用加法配置)。