Fosuserbundle: Service "fos_user.user_manager" not found

Created on 15 Aug 2018  路  1Comment  路  Source: FriendsOfSymfony/FOSUserBundle

php: 7.2.4
symfony: 4.1.3
userBundle: 2.1.2
when write in any controller code:
$userManager = $this->get('fos_user.user_manager');
make an error:

Service "fos_user.user_manager" not found: even though it exists in the app's container, the container inside "App\Controller\AdminController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session", "templating" and "twig" services. Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "AdminController::getSubscribedServices()".

>All comments

Here you can find all needed information: https://symfony.com/doc/current/service_container/3.3-di-changes.html#controllers-are-registered-as-services

Was this page helpful?
0 / 5 - 0 ratings