2017-07-07 91 views
2

我有這樣的錯誤,當我用的symfony 2.8,臭蟲config.yml也許,幫助我,請爲解決此問題,並感謝先進PHP致命錯誤:未捕獲的異常「的Symfony 分量 YAML 異常 ParseException的」

FileLoaderLoadException in FileLoader.php line 133: The file "/var/www/html/authenti/app/config/config.yml" does not contain valid YAML in /var/www/html/authenti/app/config/config.yml (which is being imported from "/var/www/html/authenti/app/config/config_dev.yml").

代碼config.yml:

imports: 
     - { resource: parameters.yml } 
     - { resource: security.yml } 
     - { resource: services.yml } 

    # Put parameters here that don't need to change on each machine where the app is deployed 
    # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration 
    parameters: 
     locale: en 

    framework: 
     #esi: ~ 
     #translator: { fallbacks: ['%locale%'] } 
     secret: '%secret%' 
     router: 
      resource: '%kernel.root_dir%/config/routing.yml' 
      strict_requirements: ~ 
     form: ~ 
     csrf_protection: ~ 
     validation: { enable_annotations: true } 
     #serializer: { enable_annotations: true } 
     templating: 
      engines: ['twig'] 
     default_locale: '%locale%' 
     trusted_hosts: ~ 
     trusted_proxies: ~ 
     session: 
      # handler_id set to null will use default session handler from php.ini 
      handler_id: ~ 
     fragments: ~ 
     http_method_override: true 

    # Twig Configuration 
    twig: 
     debug: '%kernel.debug%' 
     strict_variables: '%kernel.debug%' 

    # Doctrine Configuration 
    doctrine: 
     dbal: 
      driver: pdo_mysql 
      host: '%database_host%' 
      port: '%database_port%' 
      dbname: '%database_name%' 
      user: '%database_user%' 
      password: '%database_password%' 
      charset: UTF8 
      # if using pdo_sqlite as your database driver: 
      # 1. add the path in parameters.yml 
      #  e.g. database_path: '%kernel.root_dir%/data/data.db3' 
      # 2. Uncomment database_path in parameters.yml.dist 
      # 3. Uncomment next line: 
      #path: '%database_path%' 

     orm: 
      auto_generate_proxy_classes: '%kernel.debug%' 
      naming_strategy: doctrine.orm.naming_strategy.underscore 
      auto_mapping: true 

    # Swiftmailer Configuration 
    swiftmailer: 
     transport: '%mailer_transport%' 
     host: '%mailer_host%' 
     username: '%mailer_user%' 
     password: '%mailer_password%' 
     spool: { type: memory } 

    imports: 
     // ... 
     - { resource: security.yml } 
    // ... 
    framework: 
     // ... 
     csrf_protection: ~ 
     form: ~ 
     session: 
      handler_id: ~ 
     // ... 
    fos_user: 
     db_driver: orm 
     firewall_name: main 
     user_class: AppBundle\Entity\User 
    lexik_jwt_authentication: 
     private_key_path: %jwt_private_key_path% 
     public_key_path: %jwt_public_key_path% 
     pass_phrase:  %jwt_key_pass_phrase% 
     token_ttl:  %jwt_token_ttl% 
    // ... 
    dunglas_api: 
     title:  "%api_name%" 
     description: "%api_description%" 
     enable_fos_user: true 
    nelmio_cors: 
     defaults: 
      allow_origin: ["%cors_allow_origin%"] 
      allow_methods: ["POST", "PUT", "GET", "DELETE", "OPTIONS"] 
      allow_headers: ["content-type", "authorization"] 
      expose_headers: ["link"] 
      max_age:  3600 
     paths: 
      '^/': ~ 

的routing.yml:

app: 
    resource: '@AppBundle/Controller/' 
    type: annotation 

api: 
    resource: "." 
    type:  "api" 
    prefix: "/api" 

api_login_check: 
    path: "/login_check" 

parameters.yml.dist:

# This file is a "template" of what your parameters.yml file should look like 
    # Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production. 
    # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration 
    parameters: 
     database_host: 127.0.0.1 
     database_port: ~ 
     database_name: symfony 
     database_user: root 
     database_password: ~ 
     # You should uncomment this if you want to use pdo_sqlite 
     #database_path: "%kernel.root_dir%/data.db3" 

     mailer_transport: smtp 
     mailer_host: 127.0.0.1 
     mailer_user: ~ 
     mailer_password: ~ 

     jwt_private_key_path: %kernel.root_dir%/var/jwt/private.pem 
     jwt_public_key_path: %kernel.root_dir%/var/jwt/public.pem 
     jwt_key_pass_phrase : 'test' 
     jwt_token_ttl:  86400 

     cors_allow_origin: http://localhost:9000 

     api_name:   Your API name 
     api_description: The full description of your API 


     # A secret key that's used to generate certain security-related tokens 
     secret: ThisTokenIsNotSoSecretChangeIt 
+0

好了,這也可能只是複製/粘貼問題,但是所有的部分( import:,framework:等)需要從最左邊的列開始。您還應該在所有字符串周圍使用單引號,尤其是使用%參數%時。我懷疑你是否真的在測試之前開始使用這些文件?可能想要回滾到以前的工作版本。 – Cerad

回答

1

嘗試縮進很好,我看到了這一點,例如修復:

imports: 
     - { resource: parameters.yml } 
     - { resource: security.yml } 
     - { resource: services.yml } 

更正:

imports: 
    - { resource: parameters.yml } 
    - { resource: security.yml } 
    - { resource: services.yml } 
+0

感謝我的朋友 –

+0

很高興爲您效勞! –

+0

現在當我訪問http://localhost/authenti/web/app_dev.php/login_check我有這個結果, http://imgur.com/a/Mqs8E,這是真的結果還是這個bug?!請幫我解決這個問題 –

相關問題