Skip to content

Commit

Permalink
Make ext-sockets not required to install package (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxoff authored Jul 15, 2021
1 parent 81222b9 commit 1257e4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ $message = new Message("MSH|^~\&|||||||ADT^A01||P|2.3.1|\nPID|||3^0~4^1", null,
```

### Send messages to remote listeners

Side note: In order to run Connection you need to install PHP ext-sockets [https://www.php.net/manual/en/sockets.installation.php](https://www.php.net/manual/en/sockets.installation.php)

```php
$ip = '127.0.0.1'; // An IP
$port = '12001'; // And Port where a HL7 listener is listening
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"prefer-stable" : true,
"require": {
"php": ">=7.3",
"ext-sockets": "*",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^9",
"dms/phpunit-arraysubset-asserts": "^0.2",
"ext-pcntl": "*"
"ext-pcntl": "*",
"ext-sockets": "*"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 3 additions & 0 deletions src/HL7/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class Connection
*/
public function __construct(string $host, int $port, int $timeout = 10)
{
if (!extension_loaded('sockets')) {
throw new HL7ConnectionException('Please install ext-sockets to run Connection');
}
$this->setSocket($host, $port, $timeout);
$this->MESSAGE_PREFIX = "\013";
$this->MESSAGE_SUFFIX = "\034\015";
Expand Down

0 comments on commit 1257e4f

Please sign in to comment.