简体   繁体   English

使用Node.js / socket.io和php / mysql的Web应用程序

[英]Web application using Node.js/socket.io and php/mysql

I am relatively new to node.js and socket.io. 我对node.js和socket.io相对较新。 Currently I have a half finished private web project, which runs only with PHP with a MySQL database on the server side. 目前,我有一个半成品的私有Web项目,仅在服务器端使用带有MySQL数据库的PHP运行。 I decided to bring it to a more advanced level using socket.io, for several features within the project. 我决定使用socket.io将其提升到更高的级别,以实现项目中的一些功能。

So I read a lot about it and watched a whole bunch of tutorials. 因此,我阅读了很多,并观看了很多教程。 Also I found this and this during my research. 此外,我发现这个我的研究过程中。

My question is, if that is still the common way to develop a web application? 我的问题是,这是否仍然是开发Web应用程序的常用方法?

More exactly: to use on one event (like a form submit) both an AJAX request and a socket.emit, for those events it is necessary/wanted. 更准确地说:要在一个事件(如表单提交)上同时使用AJAX请求和socket.emit,对于这些事件,这是必需的/需要的。

The background of this thought is the following. 这种思想的背景如下。 I have a whole bunch of calculations running now in PHP. 我现在在PHP中运行大量计算。 And the node.js server runs logically in JavaScript. 并且node.js服务器在JavaScript中逻辑运行。 So I can easily implement a node.js server without changing anything on my AJAX requests. 因此,我可以轻松实现node.js服务器,而无需更改AJAX请求中的任何内容。 Or rewrite everything I have so far, to js and use only a node.js server. 或将到目前为止的所有内容重写为js,仅使用node.js服务器。

But this leads to 3 more questions: 但这又引出3个问题:

  1. Which runs possibly faster on the server side. 在服务器端运行速度可能更快。 A calculation scripted with PHP or JavaScript? 用PHP或JavaScript编写脚本的计算?
  2. How to use transactions on a node.js server while using MySQL? 使用MySQL时如何在node.js服务器上使用事务?
  3. And how great is the influence by converting a PHP array to a JSON object, what you could avoid with the usage of just the node.js server where you don't need to convert anything. 通过将PHP数组转换为JSON对象产生的影响是巨大的,仅使用无需转换任何内容的node.js服务器就可以避免这种情况。
  1. JavaScript is executed on the client side so you are limited by the user's hardware whereas PHP is executed on your server. JavaScript在客户端执行,因此您受到用户硬件的限制,而PHP在服务器上执行。 See this post for more info about performance comparaison. 有关性能比较的更多信息,请参见这篇文章
  2. I highly suggest you take a look at this pure node.js client that will perfectly do the job in your case. 我强烈建议您看一下这个纯粹的node.js客户端 ,它可以完美地完成您的案例。
  3. PHP has many functions to use on JSON data ( json_decode(), json_encode(), ... ) but Node.js don't require JSON data to be converted. PHP具有许多可用于JSON数据的功能( json_decode(), json_encode(), ...但是Node.js不需要转换JSON数据。 In the end, it really depend on your usage and how you plan to store and use that data 最后,这实际上取决于您的使用情况以及您计划如何存储和使用该数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 集成node.js,socket.io和php网页 - Integrating node.js, socket.io and php web page 使用Socket.IO / Node.JS将通知推送到PHP - Push Notifications to PHP using Socket.IO / Node.JS node.js socket.io&memcached-使用PHP会话ID作为Socket.IO昵称 - node.js socket.io & memcached - using PHP Session ID as Socket.IO Nickname 如何在node.js服务器上的PHP Web服务器和Socket.io之间创建握手? - How to create a handshake between PHP web server and Socket.io on node.js server? 使用Redis在PHP和socket.io/node.js之间进行通信 - Using Redis to communicate between PHP and socket.io/node.js 私人聊天消息使用Node.js,Socket.io,Redis in PHP - Private Chat Messaging using Node.js, Socket.io, Redis in PHP 在PHP / Codeigniter中使用node.js和socket.io的实时注释系统 - Real Time Commenting System using node.js and socket.io in PHP/Codeigniter socket.io node.js与简单的node.js ajax与php / ajax(用于数据) - socket.io node.js vs simple node.js ajax vs php/ajax (for data) Node.JS(+ Socket.io)和PHP的结合,用户和更改Socket ID的情况如何? - Combination of Node.JS(+ Socket.io) and PHP, what about users and changing Socket ID's 我们如何在不使用node.js的情况下使用socket.io进行核心php中的实时聊天对话 - How can we use socket.io for real time chat conversation in core php without using node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM