-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Difference between Controller and AbstractController #9926
Copy link
Copy link
Closed
Labels
actionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)hasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.
Milestone
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
actionableClear and specific issues ready for anyone to take them.Clear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)Ideal for your first contribution! (some Symfony experience may be required)hasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.