我想将我的第一个silex项目放在webhost上。 目前,我唯一能看到的是白页,在我的浏览器实际找到页面之前需要一段时间。
我的网站主持人:www.mijnhostingpartner.nl 我目前的结构:
/root/data
/root/logs
/root/wwwroot
/root/wwwroot/app
/root/wwwroot/src
/root/wwwroot/vendor
/root/wwwroot/web
我的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>
我的index.php: 我发现“Require_once”不起作用。 只有在echo('test1')工作之前。 “test2”未显示在屏幕上。
<?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();
答案 0 :(得分:2)
如果您获得空白页面,请检查您的网络服务器的错误日志。然后,如果可能,请在error_reporting
中启用php.ini
。对于silex,请确保在前端控制器中调用$app->run()
。
(后者似乎不是你的问题)