Search code examples
phphttptwigslim

Server Downloads Rendered Twig File instead of show it in the Browser


I got a problem with my application, on my dev environment everything works like it should. but on my hosting server, the php is interpreted but it does not show it in the browser, it just downloads a file.

the view is rendered with in slim/twig , when i make a json response instead of returning the view everything is okay.

 $apiEndpoints = json_decode(file_get_contents(__DIR__.'/ApiController/endpoints.json'));

    return $this->view->render($response, 'index.twig', [
        'apiEndpoints' => $apiEndpoints,
    ]);

the page is this one Application

I have the same environment on this server in another application there is no problem with this, I already downgraded slim/twig.

maybe someone see the problem in http header? I think it looks like it should.


Solution

  • Server is sending the response as application/x-httpd-php and your browser does not know what to do with it. Content type for HTML should be text/html.

    $ curl --include http://app.uhc-scorpions.ch/
    
    HTTP/1.1 200 OK
    Date: Fri, 17 Feb 2017 06:34:52 GMT
    Server: Apache/2.2.22 (Debian)
    X-Powered-By: PHP/7.0.10
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate
    Pragma: no-cache
    Set-Cookie: userSession_Session=2quum1alcu5siipkim6qmdqul2; path=/; HttpOnly
    Content-Length: 6310
    Content-Type: application/x-httpd-php