使用php通过WebSocket在单页Web应用程序中进行“页面更改”

I am trying to make a single page web app that runs over a websocket for all server request. After the user logs in, I want the page to change the html to display a dashboard (first page).

I have a template for the dashboard already build from a previous version. I need to find a way to input database info into template and send the page over the websocket as a string for the javascript to display.

I don't know how to fill the template using php classes without hard coding it into the class, then turning it into a string so I can send it. The dashboard is very complex and has dynamically built menus for each users per their settings and permissions.

Am I looking at this whole problem wrong? I have some experience with MVC from ruby on rails/node.js, but unfortunately this app is stuck using php. Can I use a framework with the socket? Should I have the JS load the template through https and send the data over the socket? (The JS guy would not like that).

I am running Ubuntu, apache2, php7, Ratchet WebSocket(wss), composer, and MySQL all on AWS.

查看全部
douqi5079
douqi5079
2017/12/04 23:54
  • websocket
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复