OpenSwoole\Coroutine\Server->set

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Coroutine\Server->set(array $options): void

Parameters

options

A key-value associative array of server options.

Return

None


Description

Set the server options for the coroutine server.

Options must be set before the server is started.


Example

Length Agreement

<?php

$server = new OpenSwoole\Coroutine\Server('127.0.0.1', 8080);

$server->set([
  'open_length_check' => true,
  'package_max_length' => 1024 * 1024,
  'package_length_type' => 'N',
  'package_length_offset' => 0,
  'package_body_offset' => 4,
]);

...

SSL Certificates

<?php

$server = new OpenSwoole\Coroutine\Server('127.0.0.1', 443, $ssl = true);

$server->set([
  'ssl_cert_file' => dirname(__DIR__) . '/ssl/server.crt',
  'ssl_key_file' => dirname(__DIR__) . '/ssl/server.key',
]);

...
Last updated on September 1, 2022