FOSUser on Symfony 3.3

半城伤御伤魂 提交于 2019-12-13 07:30:30

问题


This is similar to Symfony3 You have requested a non-existent service "validator.builder", while add FOSUserBundle, on vanilla Symfon3.3 instead of microkernel (in case that makes differences).

Problem:

I have a problem trying to set up FOSUser (v.2) on a Symfony 3.3:

[Symfony\Component\DependencyInjection\Exception\AutowiringFailedException]
Cannot autowire service "validator.builder": argument "$node" of method
"Symfony\Component\Config\Definition\Builder\ValidationBuilder::__construct()"
references class Symfony\Component\Config\Definition\Builder\NodeDefinition"
but no such service exists.

Browsing through online API:

  • ValidationBuilder is marked up to the 3.2 branch, although exists in github
  • NodeDefinition is also marked up to v3.2, although exists in github

Does that mean that their documentation is not up to date with the master 3.3?

Or not maintained anymore?

Context:

Following the official documentation, I first faced these problems:

  1. mailer_user cannot be null ; solved by editing parameters.yml: parameters: mailer_user: "me@example.com"
  2. non-existent-service-validator-builder ; solved by declaring service validator.builder
  3. non existent parameter kernel secret ; solved by duplicating a line in parameters.yml:

    parameters:
        secret: <-generated-upon-install->
        kernel.secret: <-duplicated-line->
    

I suppose there is a nice and clever way to get out of this problem, if anyone faced it yet?


回答1:


Solved! In service.yml, do not declare service as

validator.builder:
    class: Symfony\Component\Config\Definition\Builder\ValidationBuilder

But this way:

Symfony\Component\Config\Definition\Builder\ValidationBuilder:
    autowire: true

Once again, the official documentation had the answer!



来源:https://stackoverflow.com/questions/46217177/fosuser-on-symfony-3-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!