Home » Php » Symfony parses twig files as xml instead of html

Symfony parses twig files as xml instead of html

Posted by: admin June 30, 2018 Leave a comment

Questions:

For whatever reason. My twig files are now read as xml-files and thus I get xml errors.

I translated the first sentence.

This XML-file does not look like it has associated style information.
The document structure is displayed below.

<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>     
<title>My App</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css"/>
...
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"/>
...
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top">
...
[update]

I’ve been asked to provide configs, so I’ll provide any that has ‘xml’ in it.

config/packages/fos_rest.yaml

# Read the documentation: https://symfony.com/doc/master/bundles/FOSRestBundle/index.html
fos_rest:
    routing_loader:
            include_format: true
    format_listener:
        rules:
            - { path: ^/, prefer_extension: true, fallback_format: json, priorities: [ xml, json ] }
    view:
        view_response_listener:
            enabled: true
            force: true

/config/packages/framework.yaml

framework:
    secret: '%env(APP_SECRET)%'
    translator: { fallbacks: ["%locale%"] }
    #default_locale: en
    #csrf_protection: true
    #http_method_override: true

    # Enables session support. Note that the session will ONLY be started if you read or write from it.
    # Remove or comment this section to explicitly disable session support.
    session:
        handler_id: ~

    #esi: true
    #fragments: true
    php_errors:
        log: true

    cache:
        # Put the unique name of your app here: the prefix seed
        # is used to compute stable namespaces for cache keys.
        #prefix_seed: your_vendor_name/app_name

        # The app cache caches to the filesystem by default.
        # Other options include:

        # Redis
        #app: cache.adapter.redis
        #default_redis_provider: redis://localhost

        # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
        #app: cache.adapter.apcu

    templating:
        { engines: ['twig'] }

sensio_framework_extra:
    view:  
        { annotations: true }
Answers: