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

Bad error message when controller argument cannot be injected #23997

Copy link
Copy link
Closed
@fabpot

Description

@fabpot
Issue body actions

I've the following code:

class ConnectController extends AbstractController
{
    public function loginAction(Request $request, ConnectEntryPoint $entryPoint)
    {
    }

I get this error message:

Controller "App\Controller\ConnectController::loginAction()" requires that you provide a value for the "$entryPoint" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.

Which tells me that there is probably no ConnectEntryPoint service but it's not very explicit about why... knowing that I do have such a service... at least almost :)

But if I move the injection to the constructor like this:

class ConnectController extends AbstractController
{
    public function __construct(ConnectEntryPoint $entryPoint)
    {
    }

Then, I get the right error message with a nice hint about how to fix it:

Cannot autowire service "App\Controller\ConnectController": argument "$entryPoint" of method "__construct()" references class "SensioLabs\Connect\Security\EntryPoint\ConnectEntryPoint" but no such service exists. You should maybe alias this class to one of these existing services: "security.authentication.entry_point.sensiolabs_connect", "security.authentication.entry_point.sensiolabs_connect.website".

Can we try to get this message in the first case as well?

/cc @nicolas-grekas

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.