Paid work.. Funded by Wapplers... WebSockets for PHP - http://socketo.me/

Guys im just not getting to the point to covert my large project to nodejs… as it keeps growing and growing… at the speed that the updates and upgrades are required for the php version… i just dont get the time to even start the node conversion! And I only need the nodje.js version for 1 page of data to refresh in realtime with websockets…

So the question is… will somebody be interested … (the real smart guys) to do a working tutorial… to implement say a small database… eg … name, surname, count_one, count_two, count_three. A page with a paged query of say 50 records. and lets say a modal… with a form for count_one, count_two, count_three. and once this is submitted that the data refresh real-time? As this “basis” should be good enough to implement on bigger queries.

Using - WebSockets for PHP
Ratchet is a loosely coupled PHP library providing developers with tools to create real time, bi-directional applications between clients and servers over WebSockets.

As the tutorial makes sense online … but to implement it within the wappler code and api’s is a different story…

How much would you charge for this…?
And if you get a price… maybe some of us that really want Realtime PHP can contribute a few dollars … to get a working step by step tutorial.

1 Like

Yep, I’d be interested in the result of this project… willing to chip in some cash!

1 Like

Here’s a high level view of this would work:

  1. First, you would need to run a WebSocket server. This is a long-running process, so, independently of it being written in NodeJS or PHP, not all shared hostings would be happy with it. The good thing is, you could use one WebSocket server for all your customers - if they’re ok with that reliance on you. Or just use Pusher - whatever you choose you can swap down the road.

  2. You would tell browsers to connect to this WebSocket server and listen for any incoming messages (e.g.: “User 123 added”). The browser would then either:
    2.1) Tell AppConnect to refresh the data (which involves one API call [per browser] if you’re ok with that - easier approach if you don’t use heavy queries/lots of simultaneous users)
    OR
    2.2) Directly append the new data to the page (slightly more difficult as I would have to research on how to integrate it with Wappler)

  1. To push WebSocket data, you would just need to do an “API Action” in your Server Action.

Browser -> POST form -> Server Action -> API Call to WebSocket server
WebSocket server -> All connected browsers -> Data refresh/append

There you have the architecture of how this would work - no need to rebuild your app in NodeJS :slight_smile:

How much would you charge for this…?

I’ll be honest, I don’t have practical experience with WebSockets. While I know the basics enough to outline the architecture and write code to handle basic WebSocket streams, we must not forget that we also need to perform data isolation (and security). That is, refreshes affecting form/table 1 must not affect form/table 2, and guests should not be allowed to connect to the WebSocket server and “listen” for data changes, and that’s something I’ve never dealt it before and don’t have the availability to learn right now.

Best of luck!

2 Likes

thanks for the reply and putting time into coming up with a answer to this. As much as i want to force this to happen and really want it… really… i know that it comes with to many cons… and that at the end of the day we will have to convert our application to nodejs… its a given…

but thank you so much for doing the research and applying your mind to the solution.

Just a interesting article anyway…

The reality of PHP WebSockets

https://itnext.io/the-reality-of-php-websockets-4c680bc2bc60

I’m currently building a realtime app in Wappler.

My websocket server is a Hasura database, and my model is a “3factor / flux” app. This just means that one interface (REST in my case) updates the database while another interface (GraphQL Subscription) receives state and data changes in real-time via a websocket and updates the UI and state of the application. Those implementation details shouldn’t matter since I’m not doing anything fancy and the way in which I use websockets won’t be complicated or non-repurpose-able. For example, some people like to use two-way websockets (e.g. send the data and receive the data in the same connection) and that’s not really difficult to change the sending interface of my design to reuse the websocket connection instead of REST.

I’ll gladly release a git repo with full example to show how it works (likely a to-do app). Y’all can donate to your favourite charity instead of me.

2 Likes

Hi Spearstone. Interesting concept. Im sure a few guys will be grateful. I have opted to go down the nodejs route for my project as its just easier to then update in the future and the scale it and keep it updated … hence wanting to do all in Wappler… So i have committed to redo my project in nodejs for that reason. Thanks for your input im sure somebody will find this very useful.

I’m also building in nodejs for the wappler backend, but use https://roadrunner.dev for my resilient and scalable php functions.

im to “stupid” for that :slight_smile: :slight_smile: i can get by with the basics and im a very good copy and paste person :slight_smile: but hardcore coding… no go… im more a “creative” … hahaah… but yes its amazing how clever some of you are… …