Skip to content

Difference between Controller and AbstractController #9926

Closed
@guillbdx

Description

@guillbdx

Hi, i'm wondering if there is an error on this documentation page :
https://symfony.com/doc/current/controller.html#the-base-controller-classes-services

What's the difference between Controller or AbstractController? Not much: both are identical, except that AbstractController is more restrictive: it does not allow you to access services directly via $this->get() or $this->container->get().

Actually, both Controller and AbstractController use the ControllerTrait, which implements the protected method get(string $id) and has the protected $container property. So $this->get() and $this->container->get() are usable in a controller extending AbstractController as well as Controller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)hasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions