php - 没有扩展能够加载 "security"的配置

标签 php symfony symfony4

我正在尝试制作一个具有安全登录空间的管理员面板。我为此安装了 Security-bundle。

但是,我得到这个错误:

There is no extension able to load the configuration for "security" (in (..)/devfuzz/config/packages/security.yaml). Looked for namespace "security", found "framework", "web_server", "maker", "doctrine_cache", "doctrine", "doctrine_migrations", "twig", "swiftmailer", "sensio_framework_extra", "knp_paginator" in /home/fuzzdesize/devfuzz/config/packages/security.yaml (which is loaded in resource "/home/fuzzdesize/devfuzz/config/packages/security.yaml").

我的 Composer.json :

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "doctrine/annotations": "^1.6",
        "knplabs/knp-paginator-bundle": "^3.0",
        "sensio/framework-extra-bundle": "^5.2",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "4.2.*",
        "symfony/console": "4.2.*",
        "symfony/dotenv": "4.2.*",
        "symfony/flex": "^1.1",
        "symfony/form": "4.2.*",
        "symfony/framework-bundle": "4.2.*",
        "symfony/http-foundation": "4.2.*",
        "symfony/orm-pack": "^1.0",
        "symfony/security-bundle": "4.2.*",
        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/translation": "4.2.*",
        "symfony/twig-bundle": "4.2.*",
        "symfony/validator": "4.2.*",
        "symfony/web-server-bundle": "4.2.*",
        "symfony/yaml": "4.2.*",
        "twig/twig": "^2.0"
    },
    "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.2.*"
        }
    },
    "require-dev": {
        "symfony/maker-bundle": "^1.11"
    }
}

我的 bundles.php :

<?php

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
    Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
    Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
    Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
    Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
];

我可以看到安全性不在 bundles.php 文件中。那么我该如何添加呢?它会解决问题吗?还是我需要做其他事情?

最佳答案

security-bundle 的安装似乎没有在 bundles.php 中自动添加 bundle security 这一行。

我通过手动添加那一行解决了这个问题:

Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true ],

关于php - 没有扩展能够加载 "security"的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55279011/

相关文章:

REST API 和客户端在同一台服务器上,需要 API 身份验证吗?

php - 如何从 PhpStorm 运行 Symfony Web 服务器

html - 如何在 Symfony 4 表单中的输入上添加占位符?

php - "?"和 ":"的使用

php - Laravel 5 - 缓存记住不起作用

Symfony/Doctrine - Twig_Error_Runtime : Catchable Fatal Error: Object of class Doctrine\ORM\PersistentCollection could not be converted to string

php - Symfony 4.0 中 FilesystemCache (SimpleCache) 的依赖注入(inject)

Symfony:处理 Doctrine 关系上的 EntityNotFoundException

php - 对相关表数据进行排序

php - 为 php 安装 wso2 Web 服务时出错