I'm struggling with Symfony 3.4 and autowiring.
He here an exemple of the error message :
Argument 2 passed to App\Controller\MainController::contact() must be an instance of Swift_Mailer, null given
It's the same message with every Service I pass as argument.
There is probably something missing in the configuration but I can't figure out what...
Any clue ?
// 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}'
App\Controller\:
resource: '../src/Controller'
public: true
tags: ['controller.service_arguments']
// src/Controller/MainController.php
namespace App\Controller;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Validator\Validation;
class MainController extends AbstractController
{
public function contact(
Request $request,
\Swift_Mailer $mailer,
Validation $validation,
) { ... }
}