3
votes

In my production environment, symfony2 is showing a blank page on 404's and a 503 Service Unavailable on general php errors.

I have custom TwigTemplates under app/Resources/TwigBundle/views/Exception/error|error404|error500.html.twig

When looking in the apache error log, it is showing the error correctly, but no sign of why it is not loading the error template.

Does anybody have an idea how to solve this?

3
can you show the code for your error|error404|error500 templates?Micha
What is the http status code of the returned blank page ?j-guyon
doing further investigation, after a long time, turns out that the error template was not extending the base layout properly! thanks for support, @Micha pointed me in the right direction.apfz

3 Answers

1
votes

Clear cache:

php app/console cache:clear --env=prod --no-debug
1
votes

On a blank page, and a correct html status code, most likely the base template is not being extended correctly. in my case block content was not specified in my error template.

Error template

{#  app/Resources/Twig/views/Exception/error.html.twig #}

{% extends 'MyUIBundle::error.html.twig' %}

{% block content %}

    <!-- begin error -->
    <div class="error">
        <!-- error content -->
    </div>
    <!-- end error -->

{% endblock %}

And the base template

{#  MyUIBundle::error.html.twig #}

<body>
    <!-- begin #page-container -->
    <div id="page-container">
        {% block content '' %}
    </div>
    <!-- end #page-container -->
</body>
0
votes

Í would run the application under ´dev´ environment, see where the error is and later switch the environment back.

In web/app.php change from

$kernel = new AppKernel('prod', false);

to

$kernel = new AppKernel('dev', false);

You'll be able to see an error in a browser.