Closed gidzr closed 1 year ago
Hi @gidzr!
My apologies for the difficulties you've had installing and using our websocket libraries compatible with AMPHP v3. We are still working on releasing stable versions of all our libraries which are compatible with v3.
amphp/websocket-server
has stable tag (3.x
series) which is compatible with AMPHP v3, while amphp/websocket-client
does not, only beta tags (2.x
series). To use amphp/websocket-client
with AMPHP v3, you'll need to specify "minimum-stability": "beta"
in your composer.json. This library depends on amphp/http-client
, which only was tagged with a stable version compatible with v3 just a few minutes ago. We'll tag amphp/websocket-client
with a stable very soon.
Also apologies for the error in the README, which I've now corrected. Unfortunately it is easy for these examples to fall out of sync with code since they are not tested or statically analyzed. Improving documentation is our next major goal after tagging stable releases compatible with AMPHP v3 of all our libraries.
The two server examples in this library have JS code in the public/index.html
files. Again, more documentation is on our roadmap, however extensive JS code examples are out-of-scope for the documentation here, and easily found online.
If you have other questions I'm happy to help, either here or in another issue. I'm also frequently in the Stack Overflow PHP chat or you can reach us and other Amp users in the Telegram chat.
Hi @trowski, thanks for getting back to me so quickly.
Re stable releasing: Ah, icic. Ok, thanks for that steer. I'll have to hold out a bit longer. Re README: Yeh, for sure. definitely a hard one to keep on top of due to all the various places that code will get placed in documentation. Re JS examples, I did try some but because the libraries were out of whack, I couldn't solve for JS with other variables in play. I think I'll wait for the stable releases for websocket-client before re-testing the JS code I have.
Much appreciated for your feedback, and looking forward to using the stable v3 amphp! :)
Cheers
Hi @trowski aka A-A-ron (i hope you get that reference..)
I've been trying to implement other amphp components. I've been using Bing Chat as a starting point - it's just an amazing way to kick off a thought into the start of code.
Compared with spatie, reactphp, and guzzle, I've had the most issues getting the up-to-date correct code via Bing Chat. It always gets amp\loop wrong (instead of revolt\eventloop), it always includes yields, and always refers to outdated process functions. There's a ton of deprecated examples floating around.
I'm not sure how it would be possible to do this, I've googled a bit to try find an answer for you, but would be epic if you guys could get all your latest documentation into bing chat. If Bing was regularly solving developer queries with amphp functions that worked, amphp uptake would skyrocket.
My ten cents...
I'm a big fan and amphp as my go-to-first preference and I want to see you guys dominate!
There are so many problems I've been trying to untangle which could be separated into multiple issues, but a) it would take me a full day of work, and b) they are all really related to the same underlying problem.
Versioning.. All the recent updates have broken all the websockets and http-server functionality.
Here are some illustrative examples:
Incorrect and inconsistent "hello world" examples (documentation incorrect) Incorrect Code: Example on: https://github.com/amphp/websocket-server, https://github.com/amphp/websocket-server/blob/3.x/README.md Error at line: $websocket = new Websocket($logger, $handshakeHandler, $clientHandler); Correct line: $websocket = new Websocket($server, $logger, $acceptor, $clientHandler); Only after digging around for hours in your amphp classes and github found a second example of the same script at: https://github.com/amphp/websocket-server/examples/broadcast-server/server.php
Versioning issues: For Websocket: https://github.com/amphp/websocket-client I cannot install (composer require) the websocket-client module.. which is required for websockets So, I completely uninstalled amphp, and reinstalled websocket-client with all dependencies, but THAT results in an older version of amp/http-server, in which SocketHttpServer::createForDirectAccess (Amp\Http\Server\SocketHttpServer) doesn't exist.
None of your "hello world" examples enable me to create a websocket with JS, so that i can send and receive (hardcoded) message from PHP to client (using sleep loop "hello"), or from JS Browser to php server as a chat or command. You lack of lot of "hello world" examples, and the examples you have are complex and poorly commented/explained.
I have tested every combination but keep running into various issues which fall into the same categories above.
I really want to use Amphp.. when I was checking out v2 ages ago, it look awesome.. but returning to finally implement it after v3, it's been impossible to achieve.