简体   繁体   English

Symfony2 + NodeJS + AngularJS?

[英]Symfony2 + NodeJS + AngularJS?

I want to start the development of an real time and single-page application with authentification, actions, and notifications. 我想开始使用身份验证,操作和通知来开发实时和单页面应用程序。

Is it possible to make the back-end treatment with Symfony whom I know well, and to add NodeJS / AngularJS by above? 是否可以使用我熟悉的Symfony进行后端处理,并按上面添加NodeJS / AngularJS?

This plan will help you has to understand me. 这个计划将帮助你了解我。 Is it possible to apply it, and is it a good practice? 是否可以应用它,这是一个好习惯吗?

在此输入图像描述

First, I believe we need to clarify some misunderstandings regarding the real time and AngularJS. 首先,我认为我们需要澄清一些关于实时和AngularJS的误解。 AngularJS $http and $resource use Ajax in the background. AngularJS $ http和$ resource在后台使用Ajax。

To have real time communication where the server pushes information to the client (instead of responding to Ajax calls), you would have to use Websockets. 要实时通信服务器将信息推送到客户端(而不是响应Ajax调用),您必须使用Websockets。 There are several alternatives in this domain, for example, socket.io integrates very well with nodejs, Ratchet socketo.me is specific for PHP, or you can use a 3rd party like Pusher through github.com/pusher/pusher-angular. 在这个领域有几种选择,例如, socket.io与nodejs很好地集成,Ratchet socketo.me特定于PHP,或者你可以通过github.com/pusher/pusher-angular使用像Pusher这样的第三方。

Second, you can certainly invoke PHP scripts from nodejs, however, unless you have a very specific reason to do so, it seems to me that it defeats the purpose of using nodejs. 其次,您当然可以从nodejs调用PHP脚本,但是,除非您有非常具体的理由这样做,否则在我看来它会破坏使用nodejs的目的。 If you do not have such a requirement on use nodejs. 如果您对使用nodejs没有这样的要求。

当然可以。你可以在你的服务器上安装nodejs和symfony2。你可以使用CLI方法在Symfony2中使用nodejs。在前端你可以使用angular和nodejs(转换)。有nodejs包,它可以让你转换你的nodejs代码到浏览器(browserify)端代码,你可以使用angularjs.NodeJs有一个名为socket.io的包。你可以使用它在服务器和客户端之间建立biDirectinal连接。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM