PHP code example of hyperf / mqtt-server-incubator
1. Go to this page and download the library: Download hyperf/mqtt-server-incubator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
declare(strict_types=1);
namespace App\MQTT\Event;
use Hyperf\HttpMessage\Server\Response;
use Hyperf\MqttServer\Annotation\MQTTConnect;
use Hyperf\MqttServer\Handler\HandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
#[MQTTConnect(priority: 1)]
class MQTTConnectHandler implements HandlerInterface
{
public function handle(ServerRequestInterface $request, Response $response): Response
{
var_dump((string) $request->getBody());
return $response;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.