PHP code sample
Hi,
I tried to make a websocket connection using PHP. I have installed PHP (version 7.2.2), and added devristo/phpws library (using composer, through packagist). I followed the instructions (create composer.json etc), and I copied the code from 'code samples' and run the file (I named the file "fxdemo.php") in localhost, but it did not work, and it seemed like there were some bugs in devristo library. Here is the message I got:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 0 passed in C:\xampp\htdocs\webdev4\vendor\evenement\evenement\src\Evenement\EventEmitterTrait.php on line 70 and exactly 1 expected in C:\xampp\htdocs\webdev4\fxdemo.php:13 Stack trace: #0 C:\xampp\htdocs\webdev4\vendor\evenement\evenement\src\Evenement\EventEmitterTrait.php(70): {closure}() #1 [internal function]: Evenement\EventEmitter->emit('connect') #2 C:\xampp\htdocs\webdev4\vendor\devristo\phpws\src\Devristo\Phpws\Reflection\FullAccessWrapper.php(25): ReflectionMethod->invokeArgs(Object(Devristo\Phpws\Client\WebSocket), Array) #3 C:\xampp\htdocs\webdev4\vendor\devristo\phpws\src\Devristo\Phpws\Client\WebSocket.php(136): Devristo\Phpws\Reflection\FullAccessWrapper->__call('emit', Array) #4 C:\xampp\htdocs\webdev4\vendor\evenement\evenement\src\Evenement\EventEmitterTrait.php(70): Devristo\Phpws\Client\WebSocket->Devristo\Phpws\Client{closure}() #5 C:\xampp\htdocs\webdev4\vendor\devristo\phpws\src\Devristo\Phpws\Protocol\WebSocketT in C:\xampp\htdocs\webdev4\fxdemo.php on line 13
Can you help solve this? Thanks.
Comments
Can you try installing guzzle using composer https://github.com/guzzle/guzzle#installing-guzzle
Code sample on https://developers.binary.com/demos/ should work after this