You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> :warning: This API call does not have any effect since BBB 2.2 and was removed from BBB 2.3. Deprecated starting from version 4.0 of this library and to be removed in 4.1.
179
+
172
180
```php
173
181
$response = $bbb->getDefaultConfigXML();
174
182
@@ -180,6 +188,8 @@ $response->getRawXml();
180
188
```
181
189
182
190
#### Set default config
191
+
> :warning: This API call does not have any effect since BBB 2.2 and was removed from BBB 2.3. Deprecated starting from version 4.0 of this library and to be removed in 4.1.
192
+
183
193
```php
184
194
use BigBlueButton\Parameters\SetConfigXMLParameters;
185
195
@@ -283,8 +293,224 @@ if ($response->success()) {
283
293
}
284
294
```
285
295
296
+
### Use HTTP transports
297
+
298
+
This library allows you to replace the complete HTTP transport layer used to communicate with BigBlueButton with so called *HTTP transports*.
299
+
300
+
This can be useful if you want to manipulate the HTTP requests before being sent to BigBlueButton or to perform integration tests with this library where no real HTTP requests are desired.
301
+
302
+
Additionally, the transports allows adjusting the options for the underlying backend in a detailed way.
303
+
304
+
#### Available transports
305
+
306
+
##### CurlTransport (default)
307
+
308
+
The `CurlTransport` uses the plain `curl` extension of PHP and requires no additional libraries except for the extension.
309
+
If no explicit transport if configured while constructing the API object, the `CurlTransport` is created using some recommended default options.
310
+
311
+
Nevertheless, there may be reasons to create the CurlTransport manually. For example, to set customized cURL options.
312
+
See the following examples for usage:
313
+
314
+
This creates the `CurlTransport` with the default options as done by the `BigBlueButton` class internally if no transport given:
$bbb = new BigBlueButton('https://bbb.example.com/bigbluebutton/', 'S3cr3t', $transport);
339
+
// [...]
340
+
~~~
341
+
342
+
See [PHP documentation](https://www.php.net/manual/en/function.curl-setopt.php) for a full list of cURL options.
343
+
344
+
> :warning: Avoid creating the `CurlTransport` directly with new `new CurlTransport();` unless you exactly know what you are doing.
345
+
> This will completely avoid adding the recommended default cURL options.
346
+
347
+
##### PsrHttpClientTransport
348
+
349
+
This transport allows you to use any HTTP client built on top of [PSR-7](https://www.php-fig.org/psr/psr-7/), [PSR-17](https://www.php-fig.org/psr/psr-17/) and [PSR-18](https://www.php-fig.org/psr/psr-18/).
350
+
As PSR-17 especially is very factory-driven, this transport requires a request factory and a stream factory.
351
+
352
+
This transport requires the composer packages `psr/http-client`, `psr/http-factory` and `psr/http-message` to be installed manually.
353
+
This almost will be done by requiring package(s) providing PSR-7, PSR-17 and PSR-18.
A quick example with the [Symfony HTTP client](https://github.com/symfony/http-client) PSR-18 adapter and [nyholm/psr7](https://github.com/nyholm/psr7).
362
+
363
+
~~~php
364
+
use BigBlueButton\BigBlueButton;
365
+
use BigBlueButton\Http\Transport\Bridge\PsrHttpClient\PsrHttpClientTransport;
366
+
use Nyholm\Psr7\Factory\Psr17Factory;
367
+
use Symfony\Component\HttpClient\Psr18Client;
368
+
369
+
$psr18Client = new Psr18Client();
370
+
$psr17Factory = new Psr17Factory();
371
+
// Optional: Default headers sent with each request, argument can be left out.
372
+
$defaultHeaders = [
373
+
'X-Custom-Header' => 'custom-header-value',
374
+
];
375
+
376
+
// The $psr17Factory acts both as request and stream factory
377
+
$transport = new PsrHttpClientTransport($psr18Client, $psr17Factory, $psr17Factory, $defaultHeaders);
378
+
$bbb = new BigBlueButton('https://bbb.example.com/bigbluebutton/', 'S3cr3t', $transport);
379
+
// [...]
380
+
~~~
381
+
382
+
Another alternative is to use [php-http/discovery](https://github.com/php-http/discovery) which will find a proper PSR-17 and PSR-18 implementation based on installed packages.
383
+
This is for example desirable if you are embedding this library in an own library-styled project which should not force any vendor.
384
+
385
+
~~~php
386
+
use BigBlueButton\BigBlueButton;
387
+
use BigBlueButton\Http\Transport\Bridge\PsrHttpClient\PsrHttpClientTransport;
388
+
use Http\Discovery\Psr17FactoryDiscovery;
389
+
use Http\Discovery\Psr18ClientDiscovery;
390
+
391
+
$transport = new PsrHttpClientTransport(
392
+
Psr18ClientDiscovery::find(),
393
+
Psr17FactoryDiscovery::findRequestFactory(),
394
+
Psr17FactoryDiscovery::findStreamFactory(),
395
+
$defaultHeaders // see previous example for details
396
+
);
397
+
$bbb = new BigBlueButton('https://bbb.example.com/bigbluebutton/', 'S3cr3t', $transport);
398
+
// [...]
399
+
~~~
400
+
401
+
##### SymfonyHttpClientTransport
402
+
403
+
This transport directly allows to use the [Symfony HTTP client](https://github.com/symfony/http-client) without the detour via PSR-17 and PSR-18.
404
+
405
+
To use this transport you must install at least `symfony/http-client-contracts` and a proper implementation.
406
+
Usually it is enough to require `symfony/http-client` via Composer.
407
+
408
+
For standalone environments you can create the transport easily using the factory method.
409
+
This will pick the correct Symfony HTTP client suitable for your environment automatically in background:
410
+
411
+
~~~php
412
+
use BigBlueButton\BigBlueButton;
413
+
use BigBlueButton\Http\Transport\Bridge\SymfonyHttpClient\SymfonyHttpClientTransport;
414
+
415
+
// Optional: Default headers sent with each request, argument can be left out.
416
+
$defaultHeaders = [
417
+
'X-Custom-Header' => 'custom-header-value',
418
+
];
419
+
// Optional: Default options for each request, argument can be left out.
420
+
// See https://symfony.com/doc/current/http_client.html for details.
$bbb = new BigBlueButton('https://bbb.example.com/bigbluebutton/', 'S3cr3t', $transport);
428
+
// [...]
429
+
~~~
430
+
431
+
You can also pass a preconfigured instance of `Symfony\Contracts\HttpClient\HttpClientInterface` manually if desired:
432
+
433
+
~~~php
434
+
use BigBlueButton\BigBlueButton;
435
+
use BigBlueButton\Http\Transport\Bridge\SymfonyHttpClient\SymfonyHttpClientTransport;
436
+
use Symfony\Component\HttpClient\CurlHttpClient;
437
+
438
+
$httpClient = new CurlHttpClient();
439
+
440
+
$transport = new SymfonyHttpClientTransport(
441
+
$httpClient,
442
+
$defaultHeaders, // see previous example for details
443
+
$defaultOptions // see previous example for details
444
+
);
445
+
$bbb = new BigBlueButton('https://bbb.example.com/bigbluebutton/', 'S3cr3t', $transport);
446
+
// [...]
447
+
~~~
448
+
449
+
#### Implementing your own transport (advanced)
450
+
451
+
If the transports inside this library are not suitable for you, you can implement your own custom transport for fulfilling custom requirements:
452
+
453
+
~~~php
454
+
use BigBlueButton\Http\Transport\TransportInterface;
455
+
use BigBlueButton\Http\Transport\TransportRequest;
456
+
use BigBlueButton\Http\Transport\TransportResponse;
457
+
458
+
final class CustomTransport implements TransportInterface
459
+
{
460
+
/**
461
+
* {@inheritDoc}
462
+
*/
463
+
public function request(TransportRequest $request) : TransportResponse
464
+
{
465
+
$url = $request->getUrl();
466
+
$contentType = $request->getContentType();
467
+
// aka request body
468
+
$payload = $request->getPayload();
469
+
470
+
// [...]
471
+
472
+
return new TransportResponse($reponseBody, $jsessionId);
473
+
}
474
+
}
475
+
~~~
476
+
477
+
Your `TranportInterface` implementation must use all values provided by the `TransportRequest` object passed (currently content type, URL and payload (body)).
478
+
Based on the response by the backend you are using you must construct a proper `TransportResponse` object containing response body and the JSESSION cookie when passed by BBB.
479
+
480
+
## Run tests of this library
481
+
482
+
Before running the tests, please ensure that all development dependencies of this package are installed.
483
+
Depending on the version of composer you possibly need to run
484
+
485
+
```shell
486
+
composer install --dev
487
+
```
488
+
489
+
To run the unit tests of this library simply type
490
+
491
+
```shell
492
+
composer test
493
+
```
494
+
495
+
The integration requires additional setup as there are using a real BigBlueButton server.
496
+
You need to create a `.env.local` file to configure which server to use and the proper credentials:
0 commit comments