Symfony CMF - security.context service is not enabled, therefore can't use FOSUserBundle, solutions?

StackOverflow https://stackoverflow.com/questions/20367981

  •  28-08-2022
  •  | 
  •  

Domanda

I am trying to create a new bundle inside a symfony CMF project that uses FOSUserBundle. I have experience with symfony2 but I am new to using the cmf.

Steps I followed:

1) I installed symfony CMF using below command.

php composer.phar create-project symfony-cmf/standard-edition myproject/

2) Then I created a typical Symfony2 bundle like. Acme\MasterBundle

3) Then I added below line to composer.json and updated vendors.

"friendsofsymfony/user-bundle": "1.3.*@stable"

4) However after I install can't use it. From the original error messages it is obvious that the missing service security.context is causing this issue. (Below is composer.josn file from the project)

{
"name": "symfony-cmf/standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony CMF Standard Edition\" distribution",
"authors": [
    {
        "name": "Symfony CMF Community",
        "homepage": "https://github.com/symfony-cmf/SimpleCmsBundle/contributors"
    }
],
"autoload": {
    "psr-0": { "": "src/" }
},
"minimum-stability": "stable",
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",
    "twig/extensions": "1.0.*",
    "symfony/monolog-bundle": "2.3.*",
    "symfony/assetic-bundle": "2.3.*",
    "sensio/distribution-bundle": "2.3.*",
    "symfony-cmf/symfony-cmf": "1.0.*",
    "symfony-cmf/simple-cms-bundle": "1.0.*",
    "symfony-cmf/create-bundle": "1.0.*",
    "jackalope/jackalope-doctrine-dbal": "1.0.*",
    "doctrine/doctrine-bundle": "1.2.*",
    "doctrine/data-fixtures": "1.0.*",
    "lunetics/locale-bundle": "2.2.*",
    "liip/doctrine-cache-bundle": "1.0.*",
    "incenteev/composer-parameter-handler": "~2.0",
    "liip/imagine-bundle": "~0.12",
    "wjzijderveld/check-bundles": "1.0.*@dev",
    "sensio/generator-bundle": "2.3.*@dev",
    "friendsofsymfony/user-bundle": "1.3.*@stable",
    "doctrine/orm": "2.4.*@stable"
},
"require-dev": {
    "liip/functional-test-bundle": "1.0.*"
},
"scripts": {
    "post-install-cmd": [
        "WillemJan\\CheckBundles\\Composer\\CheckBundles::postPackageUpdate",
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Symfony\\Cmf\\Bundle\\CreateBundle\\Composer\\ScriptHandler::downloadCreateAndCkeditor",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
        "WillemJan\\CheckBundles\\Composer\\CheckBundles::postPackageUpdate",
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Symfony\\Cmf\\Bundle\\CreateBundle\\Composer\\ScriptHandler::downloadCreateAndCkeditor",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "checkbundles-ignore": [
        "Liip\\FunctionalTestBundle\\LiipFunctionalTestBundle",
        "Sensio\\Bundle\\DistributionBundle\\SensioDistributionBundle",
        "Sonata\\BlockBundle\\SonataBlockBundle",
        "Symfony\\Cmf\\Bundle\\BlockBundle\\CmfBlockBundle"
    ],
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "1.0-dev"
    }
}
}

Conclusion:

I tried running below commands and found that none of security.* services are listed.

app/console container:debug
app/console container:debug security.context

The error I from above last command is:

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The service definition "security.context" does not exist.

I would like to know how to enable security.context inside symfony CMF project.

Please help!

È stato utile?

Soluzione

You are missing configuration for the security. See the Symfony Standard edition on how to configure the security, or read the docs

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top