1

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

我遵循的步骤:

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

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

2)然后我创建了一个典型的 Symfony2 包,如。Acme\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"
    }
}
}

结论:

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

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

上面最后一个命令的错误是:

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

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

请帮忙!

4

1 回答 1

2

您缺少安全配置。有关如何配置安全性,请参阅Symfony 标准版,或阅读文档

于 2013-12-04T08:44:46.420 回答