Skip to content

Commit

Permalink
Merge pull request #23 from yadaiio/Improve_documentation
Browse files Browse the repository at this point in the history
Improve documentation
  • Loading branch information
clue committed Mar 25, 2024
2 parents 30d4e53 + 719f379 commit fdd6c0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# clue/reactphp-multicast

[![CI status](https://github.com/clue/reactphp-multicast/workflows/CI/badge.svg)](https://github.com/clue/reactphp-multicast/actions)
[![CI status](https://github.com/clue/reactphp-multicast/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-multicast/actions)
[![installs on Packagist](https://img.shields.io/packagist/dt/clue/multicast-react?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/multicast-react)

Simple, event-driven multicast UDP message client and server for [ReactPHP](https://reactphp.org/).
Expand Down Expand Up @@ -41,6 +41,10 @@ Once [installed](#install), you can use the following code to create a simple
echo server that listens for incoming multicast messages:

```php
<?php

require __DIR__ . '/vendor/autoload.php';

$factory = new Clue\React\Multicast\Factory();
$socket = $factory->createReceiver('224.10.20.30:4050');

Expand All @@ -51,7 +55,7 @@ $socket->on('message', function ($data, $remote) use ($socket) {

```

See also the [examples](examples).
See also the [examples](examples/).

## Usage

Expand Down Expand Up @@ -108,13 +112,12 @@ $socket->on('message', function ($data, $remote) use ($socket) {
});
```

This method requires PHP 5.4 (or up) and `ext-sockets`.
This method requires PHP 5.4+ and `ext-sockets`.
Otherwise, it will throw a `BadMethodCallException`.
This is a requirement because receiving multicast datagrams requires a
[level 2 multicast conformant](https://www.tldp.org/HOWTO/Multicast-HOWTO-2.html#ss2.2)
socket API.
The required multicast socket options and constants have been added with
[PHP 5.4](http://php.net/manual/en/migration54.global-constants.php) (and up).
The required multicast socket options and constants have been added with PHP 5.4+.
These options are only available to the low level socket API (ext-sockets), not
to the newer stream based networking API.

Expand Down Expand Up @@ -147,22 +150,22 @@ Please refer to the [datagram documentation](https://github.com/reactphp/datagra

## Install

The recommended way to install this library is [through Composer](https://getcomposer.org).
The recommended way to install this library is [through Composer](https://getcomposer.org/).
[New to Composer?](https://getcomposer.org/doc/00-intro.md)

This project follows [SemVer](https://semver.org/).
This will install the latest supported version:

```bash
$ composer require clue/multicast-react:^1.1
composer require clue/multicast-react:^1.1
```

See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
HHVM.
It's *highly recommended to use PHP 7+* for this project.
It's *highly recommended to use the latest supported PHP version* for this project.

The [`createSender()`](#createsender) method works on all supported platforms
without any additional requirements. However, the [`createReceiver()`](#createreceiver)
Expand All @@ -171,16 +174,16 @@ method requires PHP 5.4 (or up) and `ext-sockets`. See above for more details.
## Tests

To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org):
dependencies [through Composer](https://getcomposer.org/):

```bash
$ composer install
composer install
```

To run the test suite, go to the project root and run:

```bash
$ php vendor/bin/phpunit
php vendor/bin/phpunit
```

## License
Expand Down
5 changes: 2 additions & 3 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ public function createSender()
* });
* ```
*
* This method requires PHP 5.4 (or up) and `ext-sockets`.
* This method requires PHP 5.4+ and `ext-sockets`.
* Otherwise, it will throw a `BadMethodCallException`.
* This is a requirement because receiving multicast datagrams requires a
* [level 2 multicast conformant](https://www.tldp.org/HOWTO/Multicast-HOWTO-2.html#ss2.2)
* socket API.
* The required multicast socket options and constants have been added with
* [PHP 5.4](http://php.net/manual/en/migration54.global-constants.php) (and up).
* The required multicast socket options and constants have been added with PHP 5.4+.
* These options are only available to the low level socket API (ext-sockets), not
* to the newer stream based networking API.
*
Expand Down

0 comments on commit fdd6c0d

Please sign in to comment.