如何修复脚本 'index.php' 中格式错误的 Apache header:错误 header:在 Laravel 5.6 中注册

How To Fix Apache malformed header from script 'index.php': Bad header: Register In Laravel 5.6

如何从脚本 'index.php' 中修复格式错误的 Apache header:错误 header:在 Laravel 5.6

中注册

运行 在 Apache 2.4.29 (CenOS 7) 中

代码

enter image description here

结果

enter image description here

登录 Apache error_log 显示 ==>> [Sat Apr 21 22:04:03.967658 2018] [core:error] [pid 18494:tid 139869258323712] [client 27.55.71.124:57216] 格式错误 header 来自脚本 'index.php':错误header:注册存储库

但是运行在Xampp(本地)运行成功

谢谢

方法 ConsoleOutput::writeln 写入 stdout 但 headers 不适用于 Web 服务器,因此这没有意义。

相反,您应该在执行这部分代码时在控制台中检查您的应用程序是否 运行:

if(app()->runningInConsole()) {
    ConsoleOuput::writeln('Register Repositories');
}