Artisan服务发送带有嵌入式响应头的资产 [英] Artisan serve send assets with response headers embedded

查看:73
本文介绍了Artisan服务发送带有嵌入式响应头的资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这很明显,但是我很难过,我刚刚发现我的本地PHP环境正在交付嵌入了响应头的静态文件.

Maybe this is something obvious but I'm having a hard time, I just found out that my local PHP environment is delivering static files with the response headers embedded.

这是Fedora 20上具有PHP 5.5.11的Laravel 4.1.26,已经测试了laravel servephp -S localhost:8000 server.php,两者的结果相同.

This is Laravel 4.1.26 with PHP 5.5.11 on Fedora 20, already tested laravel serve and php -S localhost:8000 server.php, both with equal results.

我尝试使用Firefox,Opera和Chromium,看起来好像正在显示原始二进制响应:

I tried with Firefox, Opera and Chromium, it looks like is displaying the raw binary response:

这导致我所有的js文件出错.

This is causing errors on all my js files.

我尝试了curlwget -q -O -的价值,并且响应正常,没有显示标题.看起来像PHP的内置服务器问题,我应该首先在哪里挖掘?

For what is worth I tried curl and wget -q -O - and the responses are ok, no headers displayed. This looks like PHP's built-in server issue, where should I dig first?

这不是PHP的事情,如果我踩到公用文件夹并使用php -S启动服务器(忽略server.phplaravel serve)就可以了.

This is not a PHP thing, it has something to do with Laravel's emulation of mod_rewrite with the file "server.php", if I step on the public folder and launch the server with php -S (ignoring server.php and laravel serve) then is all fine.

只是缩小了搜索范围,artisan serve在具有相同PHP版本(5.5.11)的Debian 8 Jessie中可以正常运行,在Fedora环境中有所不同.

Just narrowed the search, artisan serve runs ok in Debian 8 Jessie with the same PHP version (5.5.11), something is different in the Fedora environment.

推荐答案

只需更改:

if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
   return false;
}

if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
ob_end_clean ();
   return false;
}

它为我解决了

这篇关于Artisan服务发送带有嵌入式响应头的资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆