Symfony CMF - security.context服务未启用,因此无法使用FOSUserBundle,解决方案?

时间:2013-12-04 05:52:37

标签: symfony symfony-cmf

我正在尝试在使用FOSUserBundle的symfony CMF项目中创建一个新包。我有使用symfony2的经验,但我是使用cmf的新手。

我遵循的步骤:

1)我使用以下命令安装了symfony CMF。

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

2)然后我创建了一个典型的Symfony2包。极致\ MasterBundle

3)然后我将下面的行添加到composer.json并更新了供应商。

"friendsofsymfony/user-bundle": "1.3.*@stable"
4)但是我安装后无法使用它。从原始错误消息中可以看出,缺少的服务 security.context 导致了此问题。 (下面是项目中的composer.josn文件)

{
"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"
    }
}
}

结论:

我尝试在命令下运行,发现没有列出 security。 *服务。

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

上一个命令的错误I是:

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

我想知道如何在symfony CMF项目中启用security.context。

请帮忙!

1 个答案:

答案 0 :(得分:2)

您缺少安全性配置。有关如何配置安全性的信息,请参阅Symfony Standard edition,或阅读the docs