Skip to content

Update documentation to show Dependency Injection (Symfony 4) #191

@tacman

Description

@tacman

Symfony4 makes services private by default, so the examples that show getting the client from the container no longer work without additional configuration (making the service public), or injecting the container, which is discouraged (but works).

What is the name of the class to be used when getting the client via Dependency Injection? I was hoping to simply inject \Solarium\Client, but am getting an error:

Cannot autowire argument $client of "App\Controller\MessageController::message()": it references class "Solarium\Client" but no such service exists. You should maybe alias this class to the existing "solr.client.adapter" service. 

Can you provide an example with a Symfony4 service or controller that doesn't inject the container? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions