繁体   English   中英

Symfony2中的“未定义的类安全性”

[英]“Undefined class Security” in Symfony2

我已经用Symfony2创建了一个简单的登录系统。 我已按照-

http://symfony.com/doc/current/book/security.html#using-a-traditional-login-form

我已经创建了教程中讲述的所有内容。

这是我的错误,我正在-

Attempted to load class "Security" from namespace "Symfony\Component\Security\Core" in C:/XAMPP/xamppfiles/htdocs/symfony/src/Custom/TestBundle/Controller/SecurityController.php line 15. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Sensio\Bundle\FrameworkExtraBundle\Configuration\Security.

我正在使用PHPStorm。 甚至我的IDE都显示

在此处输入图片说明

我的security.yml看起来像-

security:
    encoders:
      Symfony\Component\Security\Core\User\User: plaintext
    role_hierarchy:
      ROLE_ADMIN: [ROLE_USER]
    providers:
      chain_provider:
        chain:
          providers: [in_memory]
      in_memory:
        memory:
          users:
            admin: {password: pass, roles: ROLE_ADMIN}
    firewalls:
      main:
        pattern: /.*
        form_login:
          login_path: /login
          check_path: /login_check
          default_target_path: /
        logout:
          path: /logout
          target: /
        security: true
        anonymous: true


    access_control:
      - { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
      - { path: /.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }

您需要检查Symfony2应用程序的版本和文档的版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM