【发布时间】:2025-12-16 19:10:01
【问题描述】:
我正在从 Laravel 8 迁移到 Laravel 8 + Octane / Swoole。一切正常,但php://input 总是空的。另外,我检查了 $_POST 和 $_SERVER 的值。
file_get_contents('php://input') 被AWS SNS Message Validator 使用。
阅读php://input的任何替代方法?
PHP 代码
echo "php://input: ".file_get_contents('php://input');
使用 PHP-FPM
$ curl -i -X POST --data "dataaaa" https://example.com/aws/sns/webhook
php://input: dataaaa
使用辛烷值+Swoole
$ curl -i -X POST --data "dataaaa" https://example.com/aws/sns/webhook
php://input:
【问题讨论】:
-
php://input是 PHP 内置的,那些框架不应该改变它。 -
我想的和你一样,但是用swoole总是空的。使用 PHP-FPM 可以正常工作。
-
请注意,在 CLI SAPI 或内置网络服务器中,
php://input流包装器不适用于enctype="multipart/form-data"。见the manual for details。