88 * [ Installation] ( #Installation )
99 * [ Producer] ( #Producer )
1010 * [ Consumer] ( #Consumer )
11+ * [ TLS] ( #TLS )
1112 * [ Schema] ( #Schema )
1213 * [ Reader] ( #Reader )
1314 * [ Options] ( #Options )
@@ -47,6 +48,7 @@ composer require ikilobyte/pulsar-client-php
4748``` php
4849<?php
4950
51+ use Pulsar\Authentication\Basic;
5052use Pulsar\Authentication\Jwt;
5153use Pulsar\Compression\Compression;
5254use Pulsar\Producer;
@@ -58,9 +60,12 @@ require_once __DIR__ . '/vendor/autoload.php';
5860$options = new ProducerOptions();
5961
6062// If permission authentication is available
61- // Only JWT authentication is currently supported
63+ // use JWT authentication
6264$options->setAuthentication(new Jwt('token'));
6365
66+ // use Basic authentication
67+ //$options->setAuthentication(new Basic('user','password'));
68+
6469$options->setConnectTimeout(3);
6570$options->setTopic('persistent://public/default/demo');
6671$options->setCompression(Compression::ZLIB);
@@ -141,6 +146,7 @@ $producer->send('body',[
141146<?php
142147
143148use Pulsar\Authentication\Jwt;
149+ use Pulsar\Authentication\Basic;
144150use Pulsar\Consumer;
145151use Pulsar\ConsumerOptions;
146152use Pulsar\SubscriptionType;
@@ -151,9 +157,12 @@ require_once __DIR__ . '/vendor/autoload.php';
151157$options = new ConsumerOptions();
152158
153159// If permission authentication is available
154- // Only JWT authentication is currently supported
160+ // use JWT authentication
155161$options->setAuthentication(new Jwt('token'));
156162
163+ // use Basic authentication
164+ //$options->setAuthentication(new Basic('user','password'));
165+
157166$options->setConnectTimeout(3);
158167$options->setTopic('persistent://public/default/demo');
159168$options->setSubscription('logic');
@@ -282,6 +291,33 @@ while ($running) {
282291}
283292```
284293
294+ ## TLS
295+
296+ - Refer to the official [ documentation] ( https://pulsar.apache.org/docs/next/security-tls-transport/ ) for certificate
297+ configuration
298+
299+ - Example
300+
301+ ``` php
302+ $tls = new \Pulsar\TLSOptions('./cert.pem','./cert.key.pem');
303+
304+ // CA Cert
305+ $tls->setTrustCertsFilePath('./ca.cart.pem');
306+
307+ // optional
308+ $tls->setAllowInsecureConnection(false);
309+ $tls->setValidateHostname(true);
310+ $options->setTLS($tls);
311+
312+ $consumer = new \Pulsar\Consumer('pulsar+ssl://localhost:6651',$options);
313+ //$producer = new \Pulsar\Producer('pulsar+ssl://localhost:6651',$options);
314+
315+
316+ // or https
317+ $consumer = new \Pulsar\Consumer('https://localhost:8081',$options);
318+ //$producer = new \Pulsar\Producer('https://localhost:8081',$options);
319+ ```
320+
285321## Schema
286322
287323- Currently only supports ` INT8 ` 、` INT16 ` 、` INT32 ` 、` INT64 ` 、` DOUBLE ` 、` STRING ` 、` JSON ` ,The following code uses ` JSON Schema `
@@ -439,6 +475,11 @@ $reader->close();
439475 * DELAY_SECONDS
440476 * SEQUENCE_ID
441477 * PROPERTIES
478+ * TLSOption (v1.3.0)
479+ * __ construct(string $certFilePath, string $keyFilePath)
480+ * setTrustCertsFilePath()
481+ * setValidateHostname()
482+ * setAllowInsecureConnection()
442483
443484## MessageNotFound ErrCode (v1.2.1)
444485
0 commit comments