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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy