簡體   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