2016-04-24 115 views
-2

我有一個基於symfony3的應用程序。我確實註冊並從文檔登錄。 這是我在security.yml安全和登錄 - symfony3

security: 
encoders: 
     AppBundle\Entity\User: bcrypt 

providers: 
    our_db_provider: 
     entity: 
      class: AppBundle:User 
      property: username 

firewalls: 
    # disables authentication for assets and the profiler, adapt it according to your needs 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 

    main: 
     pattern: ^/ 
     http_basic: ~ 
     provider: our_db_provider 
      form_login: 
        login_path: login 
        check_path: login 

代碼,並在localhost是 - 在FileLoader.php線118 FileLoaderLoadException: 文件 「C:\ XAMPP \ htdocs中\遊戲\程序/配置\ security.yml」 不不包含C:\ xampp \ htdocs \ game \ app/config \ security.yml中的有效YAML(從C:\ xampp \ htdocs \ game \ app/config \ config.yml導入)。

你能告訴我我做錯了什麼嗎? 另一個代碼是從我的應用程序在這裏 - https://github.com/xrbartek/mirko

回答

3

YAML是非常特別的如何縮進將改變配置的結構。您必須在整個文件中保持一致的空格數量。

我看了一下your config,可以看到,通過運行它YAML parser有一些問題。

我已經糾正了這個以下有效YAML:

# To get started with security, check out the documentation: 
# http://symfony.com/doc/current/book/security.html 
security: 
    encoders: 
     AppBundle\Entity\User: bcrypt 

    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers 
    providers: 
     our_db_provider: 
      entity: 
       class: AppBundle:User 
       property: username 

    firewalls: 
     # disables authentication for assets and the profiler, adapt it according to your needs 
     dev: 
      pattern: ^/(_(profiler|wdt)|css|images|js)/ 
      security: false 

     main: 
      pattern: ^/ 
      http_basic: ~ 
      provider: our_db_provider 
      form_login: 
       login_path: login 
       check_path: login 

      # activate different ways to authenticate 

      # http_basic: ~ 
      # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate 

      # form_login: ~ 
      # http://symfony.com/doc/current/cookbook/security/form_login_setup.html 
      # app/config/security.yml 
+0

現在我有 - ERR_TOO_MANY_REDIRECTS和本地主機沒有工作 –

+0

好了,但是這是一個單獨的問題。您可能需要將「匿名:〜」添加到主防火牆。這個答案似乎解決了你原來的問題。 –

+0

好吧,它的工作原理,謝謝 –