Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
The OpenSwoole\HTTP\Request
object is passed to the Request
event when running a OpenSwoole HTTP server and contains all the information of a HTTP request that was made to your OpenSwoole server, for example, GET, POST, Cookies, files, headers etc.
The request object is passed to you so that you can interact with the server request and client information. You should not access this object via call-by-reference (use of the &
symbol in PHP) because the object is destroyed afterwards and may lead to undefined object errors, only access it from the event callback, this object is only valid during the lifecycle of the server request, meaning, the request object is destroyed after the request has finished.
You can use the following properties and methods to access the HTTP request and data:
OpenSwoole\HTTP\Request->header
OpenSwoole\HTTP\Request->server
OpenSwoole\HTTP\Request->get
OpenSwoole\HTTP\Request->post
OpenSwoole\HTTP\Request->cookie
OpenSwoole\HTTP\Request->rawcookie
OpenSwoole\HTTP\Request->files
OpenSwoole\HTTP\Request->rawContent
OpenSwoole\HTTP\Request->getContent
OpenSwoole\HTTP\Request->getData
OpenSwoole\HTTP\Request->create
OpenSwoole\HTTP\Request->parse
OpenSwoole\HTTP\Request->isCompleted
OpenSwoole\HTTP\Request->getMethod