Scaffoldinganddemoforinteractingwithphpiviawebsockets.
ThisshouldbeenoughtogetstartedwithaWSserverandclient.Theincludeddemowillletyoumonitorthepinheaders,selectalternatefunctionsandchangepinlevels.
InstalationInstallationshouldbedoneusingcomposerasthereareafewdependencies(especiallyforratchet-sorryaboutthisbuttheyarealljusttinysymphonycomponents).
Ifyoudon'thavecomposeralready:
$curl-sShttps://getcomposer.org/installer|php
Theninstall
$./composer.pharcreate-projectcalcinai/phpi-websocket
Alternatively,youcandownloadthecurrentreleasewithallitsdependenciesfromthereleasespage.
UsageYoucantesttheserverbyrunning
phpexamples/server.php
ThiswillrunasimpleHTTP&WebSocketserveronport9999.Ifthehostnameofthepiisnotthedefault(raspberrypi.local),you'llneedtosetittosomethingthatcanbeaccessedinserver.php
Allgoingwell,youshouldbeabletoaccesstheexampleathttps://raspberrypi.local:9999/andseesomethinglikethis:
评论