Thanks to visit codestin.com
Credit goes to github.com

Skip to content

#[CurrentUser] : Unable to guess how to get a Doctrine instance from the request information for parameter "user". #40333

Closed
@seb-jean

Description

@seb-jean

Symfony version(s) affected: 5.2.3
sensio/framework-extra-bundle: 6.1.1

Description
Hi,
I have an error when use #[CurrentUser]:
Unable to guess how to get a Doctrine instance from the request information for parameter "user".

How to reproduce

<?php

namespace App\Controller\User;

use App\Entity\User;
use App\Repository\NotificationRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\CurrentUser;

class NotificationController extends AbstractController
{
    #[Route('/notifications', name: 'user_notification_index', methods: ['GET'])]
    public function index(#[CurrentUser] User $user): Response
    {
        ...
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions