Skip to content

The attribute #[AutowireCallable] does not function as intended in the controller method #51200

@rcsofttech85

Description

@rcsofttech85

Symfony version(s) affected

6.3

Description

The attribute #[AutowireCallable] works using constructor injection, but it does not function when directly used in the controller method.

How to reproduce

#[Route(
    path: "/playground",
    name: "playground",
    methods: ["GET"]
)]
public function play(#[AutowireCallable(service: WelcomeGreet::class, method: 'greetMessage')]
                     GreetInterface $greet):Response
{
   $message = $greet->greetMessage();

   return new Response($message);

}

Error: Argument #1 ($greet) must be of type App\Interface\GreetInterface ,array given.

Possible Solution

No response

Additional Context

No 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