【问题标题】:Error $HTTP_RAW_POST_DATA is deprecated, use the php://input stream instead."错误 $HTTP_RAW_POST_DATA 已弃用,请改用 php://input 流。”
【发布时间】:2014-11-24 14:56:51
【问题描述】:

在 MAMP 上使用 PHP 5.6.2。我将 Laravel 从 4.1 升级到 4.2,在修复了 Laravel 升级文档中描述的一些错误和更改后,我终于得到了这个错误:

"Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead."

这是为什么呢?我应该在哪里更改任何代码?我没有在代码中的任何地方使用$HTTP_RAW_POST_DATA

我还按照说明更改了我的 php.ini,同样的错误...我该如何解决这个问题?

【问题讨论】:

  • 也许 laravel 使用它?
  • 然后呢?我该怎么办?我刚更新。文档说“Laravel 4.2 需要 PHP 5.4.0 或更高版本。”
  • 在 php.ini 中更改后是否重新启动了 Apache/PHP?你确定你更新了正确的 php.ini 吗? (请参阅phpinfo() 使用的路径)。我从未使用过 Laravel,但如果 $HTTP_RAW_POST_DATA 来自 Laravel,您不必修复框架源代码中的代码。
  • 是的,我重新启动并更改了正确的ini
  • 非常感谢你们俩。我仔细检查并在我的 php.ini 中犯了一个错误。现在可以了!

标签: php laravel laravel-4 mamp


【解决方案1】:

解决这个问题的方法是编辑右php.ini。然后一切正常。

【讨论】:

  • 好答案,但更可怕的是:Laravel 5 不会在即将到来的 PHP 7 上运行吗?
  • Laravel 目前正在 PHP7 开发版本上运行。
  • 在 PHP ini 中编辑什么??
【解决方案2】:

请使用:

Content-Type = application/x-www-form-urlencoded 

解决这个问题。

【讨论】:

    【解决方案3】:

    转到您的 PHP.ini 并搜索“always_populate_raw_post_data”并将值设置为 -1,例如:

    ; Always populate the $HTTP_RAW_POST_DATA variable. PHP's default behavior is
    ; to disable this feature and it will be removed in a future version.
    ; If post reading is disabled through enable_post_data_reading,
    ; $HTTP_RAW_POST_DATA is *NOT* populated.
    ; http://php.net/always-populate-raw-post-data
    always_populate_raw_post_data = -1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 2014-04-13
      相关资源
      最近更新 更多