Peter Van Gorp
Peter Van Gorp

Reputation: 15

Deployment silex: white page

I want to put my first silex project online on a webhost. Currently the only thing I can see is a white page, and it takes a while before my browser actually finds the page.

My webhost: www.mijnhostingpartner.nl My current structure:

/root/data
/root/logs
/root/wwwroot
/root/wwwroot/app
/root/wwwroot/src
/root/wwwroot/vendor
/root/wwwroot/web

My web.config:

<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
    <system.webServer>
      <directoryBrowse enabled="false" />
       <rewrite>
        <rules>
            <rule name="Silex Front Controller" stopProcessing="true">
                <match url="^(.*)$" ignoreCase="false" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
    <defaultDocument>
        <files>
            <clear />
            <add value="Default.html" />
            <add value="Default.htm" />
            <add value="Default.asp" />
            <add value="index.htm" />
            <add value="Default.aspx" />
            <add value="index.html" />
            <add value="index.php" />
            <add value="index.asp" />
        </files>
    </defaultDocument>
  </system.webServer>
</configuration>

My index.php: I found out that the "Require_once" did not work. Only until echo('test1') works. "test2" is not shown on the screen.

<?php

// PHP 5.4's built in server can now server static files
// @see http://silex.sensiolabs.org/doc/web_servers.html#php-5-4
$filename = __DIR__ . preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
if (php_sapi_name() === 'cli-server' && is_file($filename)) {
    return false;
}
echo('test1');
// Require the app and run it
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'app.php';
echo('test2');

$app->run();

Upvotes: 0

Views: 856

Answers (1)

igorw
igorw

Reputation: 28259

If you get a blank page, check your webserver's error logs. Then enable error_reporting in php.ini if possible. And for silex, make sure you are calling $app->run() in the front controller.

(the latter does not seem to be the issue in your case)

Upvotes: 2

Related Questions