最快的方式来消除和忘记在PHP中的JSON POST [英] Fastest way to Fire and Forget a JSON POST in PHP
问题描述
我目前正在为一个网站建立/实现一个日志记录系统,我正在使用PHP。日志系统的工作方式是我发送一个JSON请求到localhost和json的记录(基本上,无论如何。
I'm currently in the process of building/implementing a logging system for a website I'm working on that's in PHP. The way the logging system works is I send a JSON request to localhost and that json gets logged (basically, anyway.
我的问题是
什么是最快的方式,我可以使用JSON POST快速启动和忘记调用有什么方法可以触发和忘记cURL?
what's the fastest way I can make a quick fire and forget call with a JSON POST? Is there a way to fire and forget with cURL?
推荐答案
有多种方法:您可以使用 curl_multi 功能的 php_curl
扩展,它允许您使用cURL发送异步HTTP请求,这需要扩展。 GuzzlePHP 为cURL的大部分功能提供了一个大型包装,包括 curl_multi
如果你正在寻找一个面向对象的方法。
PHP的套接字也支持异步通信,实现这个HTTP协议的库可用这里 [客户端是用纯PHP编写的,没有依赖于cURL,但支持异步请求,完全符合HTTP 1.1规范] 。
There are multiple ways to do it: you could use the curl_multi functionality of the php_curl
extension, which allows you to send asynchronous HTTP requests using cURL, but this requires that extension. GuzzlePHP provides a large wrapper around much of the functionality of cURL, including the curl_multi
features if you are looking for an object-oriented approach.
PHP's sockets also support asynchronous communications, a library which implements this for the HTTP protocol is available here [the client is written in "pure" PHP and has no dependency on cURL but supports asynchronous requests and fully complies with the HTTP 1.1 spec].
这篇关于最快的方式来消除和忘记在PHP中的JSON POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!