How to extend Request #1085
-
For example: <?php
use Workerman\Protocols\Http\Request as WorkermanRequest;
class Request extends WorkermanRequest
{
public function getData()
{
return 'here is your data';
}
} So i can use it like: $worker->onMessage = function (TcpConnection $connection, Request $req) {
$connection->send($req->getData());
}; |
Beta Was this translation helpful? Give feedback.
Answered by
erwinstone
Jan 10, 2025
Replies: 1 comment
-
Got it: <?php
use Workerman\Protocols\Http\Request as WorkermanRequest;
class MyRequest extends WorkermanRequest
{
public function getData()
{
return 'here is your data';
}
} use Workerman\Protocols\Http;
$worker->onWorkerStart = function () {
Http::requestClass(MyRequest::class);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
erwinstone
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got it: