Symfony 3.4
Service access errors:
The "fos_user.profile.form.factory" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
There is a solution, this is to make every service public in config/services.yaml:
fos_user.profile.form.factory:
class: 'FOS\UserBundle\Form\Factory\FormFactory'
arguments: ["@form.factory", '%fos_user.profile.form.name%', '%fos_user.profile.form.type%', '%fos_user.profile.form.validation_groups%']
public: true
but this is not a good option
The service "fos_user.profile.form.factory" was given as an example. This problem with all services.
will this be decided in a bandle?
You should either make it public, or stop using the container directly and use dependency injection instead.
In symfony 4 all services are not public by default. So you should stop using container as it proposes to you the quoted message. Instead you need to inject the service directly. I think there is no need to make them public.
Also, what's the use-case for using the fos_user.profile.form.factory service? This should mostly be an internal service that users don't need to think about. But maybe there is a use-case I'm not thinking of?
this should indeed be an internal service, which is why we have not made it public (as we refactored our own controller were refactored to stop relying on them.
@lloonnyyaa are you using the dev version or the stable release ? The refactoring is not yet released.
When I use Symfony Flex 3.4 + "friendsofsymfony/user-bundle": "^2.0" (2.0.2)
I'm having errors:
Profile edit: http://joxi.ru/Y2Ll85YtnBygB2
Change password: http://joxi.ru/LmGg7MeFRaQ9Ym
Registration: http://joxi.ru/p27ZgP9U0wMgpm
etc
after that I started using 2.1.x-dev version of user-bundle, these errors disappeared.
but there are other errors with "... .form.type" services.
For example, change password http://joxi.ru/RmzBvZxTWaqKkm
I added the following code to the configs (make this services public), and everything works well:
fos_user.profile.form.type:
class: 'FOS\UserBundle\Form\Type\ProfileFormType'
arguments: ['%fos_user.model.user.class%']
public: true
tags:
- { name: form.type, alias: fos_user_profile }
fos_user.change_password.form.type:
class: 'FOS\UserBundle\Form\Type\ChangePasswordFormType'
arguments: ['%fos_user.model.user.class%']
public: true
tags:
- { name: form.type, alias: fos_user_change_password }
fos_user.registration.form.type:
class: 'FOS\UserBundle\Form\Type\RegistrationFormType'
arguments: ['%fos_user.model.user.class%']
public: true
tags:
- { name: form.type, alias: fos_user_registration }
Also, what's the use-case for using the
fos_user.profile.form.factoryservice? This should mostly be an internal service that users don't need to think about. But maybe there is a use-case I'm not thinking of?
Using 'fos_user.registration.form.factory' service for manual trigger of the 'FOSUserEvents::REGISTRATION_SUCCESS' event, for sending confirmation mail, when using FOSUserBundle together with api-platform?
If someone comes from google and get the error:
The "fos_user.profile.form.factory" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
Or whatever other fos_user service.
Since Symfony 3.4 the services are private by default.
To access services, you must inject in your controller:
use FOS\UserBundle\Form\Factory\FormFactory
class YourController
{
private $formFactory;
public function __construct(FormFactory $formFactory)
{
$this->formFactory = $formFactory;
}
}
In your services.yaml:
App\MainBundle\Controller\YourController:
public: true
arguments:
$formFactory: '@fos_user.profile.form.factory'
This ticket should be closed
Most helpful comment
When I use Symfony Flex 3.4 + "friendsofsymfony/user-bundle": "^2.0" (2.0.2)
I'm having errors:
Profile edit: http://joxi.ru/Y2Ll85YtnBygB2
Change password: http://joxi.ru/LmGg7MeFRaQ9Ym
Registration: http://joxi.ru/p27ZgP9U0wMgpm
etc
after that I started using 2.1.x-dev version of user-bundle, these errors disappeared.
but there are other errors with "... .form.type" services.
For example, change password http://joxi.ru/RmzBvZxTWaqKkm
I added the following code to the configs (make this services public), and everything works well:
fos_user.profile.form.type: class: 'FOS\UserBundle\Form\Type\ProfileFormType' arguments: ['%fos_user.model.user.class%'] public: true tags: - { name: form.type, alias: fos_user_profile } fos_user.change_password.form.type: class: 'FOS\UserBundle\Form\Type\ChangePasswordFormType' arguments: ['%fos_user.model.user.class%'] public: true tags: - { name: form.type, alias: fos_user_change_password } fos_user.registration.form.type: class: 'FOS\UserBundle\Form\Type\RegistrationFormType' arguments: ['%fos_user.model.user.class%'] public: true tags: - { name: form.type, alias: fos_user_registration }