【发布时间】:2014-09-06 23:19:26
【问题描述】:
我正在尝试在现有项目中的新 (Windows 8) 笔记本电脑上开始工作,该项目在我以前的 (Mac OS X) 机器和它部署到的所有 (Linux) 服务器上运行良好。
我已经从 git 克隆,运行 composer,app/console 工作正常,我已经正确设置了配置文件,创建了数据库并检查了数据库架构是否正常,清除了缓存等等以前做过一千次。
但是现在我遇到了一个我以前从未遇到过的错误,我不知道它是否与更新的依赖项有关,这些依赖项可能不一定使用与以前完全相同的版本,或者只是我一种在 Windows 环境下的新工作:
[1] RuntimeException: Failed to start the session because headers have already been sent by "" at line 0.
at n/a
in C:\Users\David\Sites\my-project\app\cache\dev\classes.php line 103
at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
in C:\Users\David\Sites\my-project\app\cache\dev\classes.php line 183
at Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->getBag('attributes')
in C:\Users\David\Sites\my-project\app\cache\dev\classes.php line 475
at Symfony\Component\HttpFoundation\Session\Session->has('_security.last_error')
in C:\Users\David\Sites\my-project\vendor\friendsofsymfony\user-bundle\FOS\UserBundle\Controller\SecurityController.php line 28
at FOS\UserBundle\Controller\SecurityController->loginAction(object(Request))
in line
at call_user_func_array(array(object(SecurityController), 'loginAction'), array(object(Request)))
in C:\Users\David\Sites\my-project\app\bootstrap.php.cache line 2841
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in C:\Users\David\Sites\my-project\app\bootstrap.php.cache line 2815
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in C:\Users\David\Sites\my-project\app\bootstrap.php.cache line 2944
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in C:\Users\David\Sites\my-project\app\bootstrap.php.cache line 2245
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in C:\Users\David\Sites\my-project\web\app_dev.php line 29
【问题讨论】:
-
这可能是由文件编码引起的。当你将它克隆到windows并用文本编辑器打开它时,文件编码可能会改变。
-
您的其他服务器可能启用了输出缓冲。出现此问题的原因是您在尝试设置标头之前输出了 html(有意或启用了 display_errors)。您可以使用
app\bootstrap.php顶部的ob_start()来解决此问题。
标签: php symfony-2.3