I am integrating FOSUserBundle in my application and I am trying to run php bin/console doctrine:migration:diff after following the recommended set-up.
I am systematically getting a:
In ArrayNode.php line 319:
Unrecognized option "resource" under "fos_user"
Yet, I have set the following in my config/packages/routing.yaml:
framework:
router:
strict_requirements: ~
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
What am I doing wrong? I have "friendsofsymfony/user-bundle": "~2.0" in my composer.json and ran composer update.
Update
My fos_user.yaml is:
fos_user:
db_driver: orm
firewall_name: main
user_class: App\Entity\Admin\User
from_email:
address: no_reply#xxx.com
sender_name: xxx
Dlondero's suggestion fixed the issue, the fos_user configuration should be set in config/routes.yaml.
From documentation, routes are never automatically added in configuration.
move the :
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
into config/routes.yaml insted of confing/packages/routing.yml
If I am not wrong, config/packages/routing.yaml file is not for routes, it is the config file for routing bundle, you can not put your routing configs to there. Instead, you should put them under config/routes folder, as bundle_name.yml.
Like this, eg. config/routes/imagine.yml:
_liip_imagine:
resource: "#LiipImagineBundle/Resources/config/routing.yaml"
In my case with Symfony 4.3.2 skeleton
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
should be pasted in
config/routes/annotations.yaml
and
php bin/console debug:router
displays all the fos_user routes
Related
I cannot install the FOSUserBundle.
I configured config/config.yml as follows:
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: App\Entity\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
But when I run this command:
composer require friendsofsymfony/user-bundle "~2.0"
I get the error:
The child node "db_driver" at path "fos_user" must be configured
Any hints why this is happening?
All of this config information should not be stored in config/config.yml in Symfony 4 (in Symfony 3, this would be correct). Instead, you have to create a config file config/packages/fos_user.yaml and save this information there. You then can remove config/config.yml.
I am new with Symfony4, and creating Login Form with FOSUserBundle. And I got stuck at step 5 mentioned in this article. When it says:
Add the following configuration to your config.yml file according to
which type of datastore you are using.
# app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
The problem is that in symfony4, there is no app folder, and no simple config.yml file in config folder.
I think this article might be working with older versions, but for Symfony4, it may need some amendments.
Can any body suggest how to fix it?
Why not to create it config/packages/fos.yaml ?
Or add in one of existing config/packages/foo.yaml ?
https://symfony.com/doc/current/configuration.html
for that problem you can try this:
Create fos_user.yaml file under config/packages folder then you can add the configuration code as usual, symfony4 will load it automatically.
As Arnold Richmon indicated. Also, in the fos_user.yaml file you need to add config options as:
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: App\Entity\YourUserEntityClass
from_email:
address: "youremail#yourdomain.whatever"
sender_name: "yoursendername"
to complete with service:mailer and resume, create:
config/packages/fos_user.yaml
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: App\Entity\YourUserEntityClass
service:
mailer: fos_user.mailer.twig_swift
from_email:
address: "youremail#yourdomain.whatever"
sender_name: "yoursendername"
In Symfony 4 ,the new config/ directory is the equivalent of the current app/config/ directory but with a very different layout.
Check this link for more details: https://symfony.com/blog/symfony-4-a-new-way-to-develop-applications
I am trying to update doctrine schema after installation FOSUser Bundle 2.0 but I keep getting this error:
In ArrayNode.php line 238:
The child node "db_driver" at path "fos_user" must be configured.
File config.yaml is configurated propertly in location /config/config.yaml:
framework:
translator: ~
fos_user:
db_driver: orm
firewall_name: main
user_class: Entity\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
I tried to solve it via official tutorial: http://symfony.com/doc/master/bundles/FOSUserBundle/index.html#prerequisites
I tried to do step 5 first and than rerun step 1. But still the same error.
Any ideas?
In symfony 4.x you need to create a bundle_name.yaml file instead of config.yaml
So, in this case create file fos_user.yaml in config/packages folder.
In that file you place the configuration for FOSUserBundle, like so:
fos_user:
db_driver: orm
firewall_name: main
user_class: Entity\User
from_email:
address: '%env(resolve:USER_ADDRESS)%'
sender_name: '%env(resolve:SENDER_NAME)%'
framework:
templating:
engines: ['twig', 'php']
Of course, defining the address and sender_name in .env file as constants or provide them directly with: "%mailer_user%"
use composer require friendsofsymfony/user-bundle dev-master or go to their packagist page and get the latest version FOSUserBundle Packagist
That should make it install without errors.
If you need to figure out what has changed between symfony version 3.x and 4.x i suggest checking out this article: Configuration Structure - taken from symfony blog A new way to develop applications
try to indent like this:
fos_user:
db_driver: orm
firewall_name: main
user_class: Entity\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
Because yml file needs to be written and indent well with all spaces necessary
I'm trying to update a Symfony 3.4 application to Symfony 4. On my current applications I always share a local AdminBundle folder inside src. I know Symfony 4 recommends to be "bundle-less" now. But this AdminBundle is the base for most of my projects, and sometimes I make some updates to it that can be deployed to all my projects just pushing to the repository.
I tried to move by AdminBundle inside src but obviously that's not working. Could anyone detail the recipe or configuration needed to make this Bundle work under Symfony 4 in a generic way?
If this is not possible what's the best way to create a reusable code in symfony 4?
I'm currently using a similiar approach:
I've got a "CoreBundle" for shared Services, Entites, Subscribers etc under "src".
In order to make this usable i had to edit the following:
config/maker.yaml -> to use make:entity and create under CoreBundle
maker:
root_namespace: 'App\CoreBundle'
config/packages/doctrine.yaml modify -> to get the Entities from CoreBundle
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/CoreBundle/Entity'
prefix: 'App\CoreBundle\Entity'
alias: App
config/services.yaml add -> to import all SymfonyLike Classes
###> CoreBundle ###
App\CoreBundle\:
resource: '../src/CoreBundle/*'
exclude: '../src/CoreBundle/{DependencyInjection,Entity,Model,Migrations,Tests}'
App\CoreBundle\Controller\:
resource: '../src/CoreBundle/Controller'
tags: ['controller.service_arguments']
###< CoreBundle ###
config/* add -> where i wanted to import a separate config file
imports:
- { resource: '../../src/CoreBundle/Resources/config/*.yaml' }
trying to install FOSUserBundle bundle from below link How to install 3rd party Bundles but getting this error :
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The child node "db_driver" at path "fos_user" must be configured.
You have forgotten to add the configuration for FOSUserBundle in your app/config/config.yml or at least did not provide a value for fos_user.db_driver.
You have to configure at least the db_driver , firewall and your user-class otherwise the configuration will throw an InvalidConfigurationException.
# app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Acme\UserBundle\Entity\User
Please see the documentation chapter Step 5: Configure the FOSUserBundle.
I solve similar error by updating composer : /usr/local/bin/composer self-update.
May this help.