Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@rcsofttech85

Description

@rcsofttech85
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.