Skip to content

Commit 0951bd4

Browse files
committed
Merge branch 'master' into merge-upstream
2 parents 1488b7e + 3f09558 commit 0951bd4

53 files changed

Lines changed: 4376 additions & 156 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file must exist to enable loading .env.local but is currently not used.

.github/workflows/ci.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,40 @@ on:
55
pull_request:
66

77
jobs:
8+
PHP_Lowest:
9+
name: PHP wth lowest dependencies
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php-versions: ['7.2']
15+
experimental: [false]
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
- name: Setup PHP, with composer and extensions
21+
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
22+
with:
23+
php-version: ${{ matrix.php-versions }}
24+
extensions: bcmath, ctype, fileinfo, json, mbstring, dom, ldap, pdo, tokenizer, xml, mysql, sqlite
25+
coverage: xdebug
26+
- name: Downgrade phpunit for php7.2
27+
run: composer update phpunit/phpunit -W
28+
- name: Update to lowest php dependencies
29+
run: composer update --prefer-lowest
30+
- name: Install php dependencies
31+
run: composer install --dev --no-interaction
32+
- name: Execute tests without coverage
33+
run: vendor/bin/phpunit --testsuite="BigBlueButton test suite"
34+
835
PHP:
936
name: PHP ${{ matrix.php-versions }}
1037
runs-on: ubuntu-latest
1138
strategy:
1239
fail-fast: false
1340
matrix:
14-
php-versions: ['7.2','7.3','7.4']
41+
php-versions: ['7.2','7.3','7.4','8.0']
1542
experimental: [false]
1643
include:
1744
- php-versions: '8.1'
@@ -39,15 +66,15 @@ jobs:
3966
if: ${{ !matrix.experimental }}
4067
run: |
4168
mkdir -p build/logs
42-
vendor/bin/phpunit --coverage-clover=build/logs/coverage.xml
69+
vendor/bin/phpunit --coverage-clover=build/logs/coverage.xml --testsuite="BigBlueButton test suite"
4370
- name: Execute tests without coverage
4471
if: ${{ matrix.experimental }}
45-
run: vendor/bin/phpunit
72+
run: vendor/bin/phpunit --testsuite="BigBlueButton test suite"
4673
continue-on-error: true
4774
- name: Coveralls
48-
if: matrix.php-versions == '7.2'
4975
env:
50-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
76+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
if: ${{ matrix.php-versions == '7.2' && env.COVERALLS_REPO_TOKEN != null }}
5178
run: vendor/bin/php-coveralls --coverage_clover=build/logs/coverage.xml -v
5279

5380

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ composer.phar
1111
cghooks.lock
1212

1313
.phpunit.result.cache
14+
15+
# Local environment variables
16+
/.env.local
17+
/.env.*.local

README.md

Lines changed: 229 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Inc.**
1818
* [Requirements](#requirements)
1919
* [Installation](#installation)
2020
* [Basic usage](#basic-usage)
21-
* [Test if API url and secret are valid](#test-if-api-url-and-secret-are-valid)
21+
* [Test if API url and secret are valid](#test-if-api-url-and-secret-are-valid)
2222
* [Documentation](#closed_book-documentation)
2323
* [Administration](#administration)
2424
* [Get API version](#get-api-version)
@@ -35,9 +35,15 @@ Inc.**
3535
* [Get recordings](#get-recordings)
3636
* [Publish recordings](#publish-recordings)
3737
* [Delete recordings](#delete-recordings)
38+
* [Use HTTP Transports](#use-http-transports)
39+
* [Available transports](#available-transports)
40+
* [CurlTransport (default)](#curltransport-default)
41+
* [PsrHttpClientTransport](#psrhttpclienttransport)
42+
* [SymfonyHttpClientTransport](#symfonyhttpclienttransport)
43+
* [Implementing your own transport (advanced)](#implementing-your-own-transport-advanced)
44+
* [Run tests of this library](#run-tests-of-this-library)
3845
* [Submitting bugs and feature requests](#submitting-bugs-and-feature-requests)
3946

40-
4147
## :question: Why should I use a fork?
4248
To explain why you should use a fork, we have to explain why we created our own
4349
fork. While BigBlueButton is a great product, contributing as an external
@@ -78,7 +84,7 @@ composer require littleredbutton/bigbluebutton-api-php
7884
To make any requests to your BigBlueButton instance, you have to create an API object:
7985

8086
```php
81-
use BigBlueButton/BigBlueButton;
87+
use BigBlueButton\BigBlueButton;
8288

8389
$bbb = new BigBlueButton($apiUrl, $apiSecret);
8490
```
@@ -169,6 +175,8 @@ $response = $bbb->endMeeting($endMeetingParams);
169175
```
170176

171177
#### Get default config
178+
> :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+
172180
```php
173181
$response = $bbb->getDefaultConfigXML();
174182

@@ -180,6 +188,8 @@ $response->getRawXml();
180188
```
181189

182190
#### 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+
183193
```php
184194
use BigBlueButton\Parameters\SetConfigXMLParameters;
185195

@@ -283,8 +293,224 @@ if ($response->success()) {
283293
}
284294
```
285295

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:
315+
316+
~~~php
317+
use BigBlueButton\BigBlueButton;
318+
use BigBlueButton\Http\Transport\CurlTransport;
319+
320+
$transport = CurlTransport::createWithDefaultOptions();
321+
$bbb = new BigBlueButton('https://bbb.example.com/bigbluebutton/', 'S3cr3t', $transport);
322+
// [...]
323+
~~~
324+
325+
To set custom cURL options - like additional HTTP headers to be sent and custom timeouts:
326+
327+
~~~php
328+
use BigBlueButton\BigBlueButton;
329+
use BigBlueButton\Http\Transport\CurlTransport;
330+
331+
$transport = CurlTransport::createWithDefaultOptions([
332+
CURLOPT_CONNECTTIMEOUT => 5,
333+
CURLOPT_TIMEOUT => 10,
334+
CURLOPT_HTTPHEADER => [
335+
'X-Custom-Header: custom-header-value',
336+
],
337+
]);
338+
$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.
354+
355+
To discover proper packages, see packagist.org:
356+
357+
* [psr/http-client-implementation](https://packagist.org/providers/psr/http-client-implementation)
358+
* [psr/http-factory-implementation](https://packagist.org/providers/psr/http-factory-implementation)
359+
* [psr/http-message-implementation](https://packagist.org/providers/psr/http-message-implementation)
360+
361+
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.
421+
$defaultOptions = [
422+
'timeout' => 5,
423+
'max_duration' => 10,
424+
];
425+
426+
$transport = SymfonyHttpClientTransport::create($defaultHeaders, $defaultOptions);
427+
$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:
497+
498+
```shell
499+
echo "BBB_SERVER_BASE_URL=https://bbb.example/bigbluebutton/" > env.local
500+
echo "BBB_SECRET=S3cr3t" >> .env.local
501+
```
502+
503+
It is also possible to pass both variables as real environment variables by using e.g. `export` in your shell.
504+
505+
To run the integration tests of this library then type
506+
507+
```shell
508+
composer test-integration
509+
```
510+
286511
## Submitting bugs and feature requests
287512

288513
Bugs and feature request are tracked on [GitHub](https://github.com/littleredbutton/bigbluebutton-api-php/issues)
289514

290515
[BigBlueButton API]: https://docs.bigbluebutton.org/dev/api.html
516+

0 commit comments

Comments
 (0)