Alaa Estar
Alaa Estar

Reputation: 11

I can't install the user bundle from sonata

I'm triying to install the user bundle from symfony sonata with:

composer require sonata-project/user-bundle

following the documentation in:

https://sonata-project.org/bundles/user/4-x/doc/reference/installation.html

but it always bring me the error

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!
!!  In ArrayNode.php line 224:
!!
!!    The child node "db_driver" at path "fos_user" must be configured.
!!
!!
!!

here's my composer.json file

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": ">=7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "composer/package-versions-deprecated": "1.11.99.1",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.2",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.8",
        "phpdocumentor/reflection-docblock": "^5.2",
        "sensio/framework-extra-bundle": "^5.1",
        "sonata-project/admin-bundle": "^3.90",
        "sonata-project/doctrine-orm-admin-bundle": "^3.30",
        "symfony/asset": "4.4.*",
        "symfony/console": "4.4.*",
        "symfony/dotenv": "4.4.*",
        "symfony/expression-language": "4.4.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "4.4.*",
        "symfony/framework-bundle": "4.4.*",
        "symfony/http-client": "4.4.*",
        "symfony/intl": "4.4.*",
        "symfony/mailer": "4.4.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/process": "4.4.*",
        "symfony/property-access": "4.4.*",
        "symfony/property-info": "4.4.*",
        "symfony/proxy-manager-bridge": "4.4.*",
        "symfony/security-bundle": "4.4.*",
        "symfony/serializer": "4.4.*",
        "symfony/translation": "4.4.*",
        "symfony/twig-bundle": "^4.4",
        "symfony/validator": "4.4.*",
        "symfony/web-link": "4.4.*",
        "symfony/yaml": "4.4.*",
        "twig/extra-bundle": "^2.9",
        "twig/twig": "^2.9"
    },
    "require-dev": {
        "symfony/browser-kit": "^4.4",
        "symfony/css-selector": "^4.4",
        "symfony/debug-bundle": "^4.4",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "^5.2",
        "symfony/stopwatch": "^4.4",
        "symfony/var-dumper": "^4.4",
        "symfony/web-profiler-bundle": "^4.4"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "4.4.*"
        }
    }
}

befor the this error there was an other error that told me to change the twig version to an older one so first i changed twig/extra-bundle": "^2.12|^3.0" twig/twig": "^2.12|^3.0"

to twig/extra-bundle": "^2.9","twig/twig": "^2.9"

and then this happend, what should i do ?

Upvotes: 1

Views: 359

Answers (3)

Alaa Estar
Alaa Estar

Reputation: 11

So here's what i did to make it finally work first i created a fos_user.yaml file in config/packages/fos_user.yaml like this

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: App\Entity\SonataUserUser
    group:
        group_class: App\Entity\SonataUserGroup
        group_manager: sonata.user.orm.group_manager
    service:
        user_manager: sonata.user.orm.user_manager
    from_email:
        address: "%mailer_user%"
        sender_name: "%mailer_user%"

then i created the parameter %mailer_user% in config/service.yaml like this

parameters:
    mailer_user: -

finally i added this to framework.yaml

framework:
    templating:
            engines: ['twig', 'php']

and it installed successfully but i did have to add the remaining files and configurations and other code manually that are present in the doc of sonata.

thank you for your help

Upvotes: 0

Vinci
Vinci

Reputation: 1286

Try to create fos_user.yaml in packages and add this code

fos_user.yaml

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Entity\User
    from_email:
        address: "%mailer_user%"
        sender_name: "%mailer_user%"

and in your framework.yaml,add this code framework.yaml

framework:
    templating:
        engines: ['twig', 'php']

Upvotes: 0

azibom
azibom

Reputation: 1934

Just you need to add this configuration to your config file, go to this path app/config/config.yml and then add this lines to the end of your config.yml file

# app/config/config.yml
fos_user:
     db_driver: orm # other valid values are 'mongodb' and 'couchdb'
     firewall_name: main
     user_class: UserBundle\Entity\User
     from_email:
         address: "%mailer_user%"
         sender_name: "%mailer_user%"

Upvotes: 1

Related Questions