2017-07-07 175 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?!请帮我解决这个问题 –

相关问题