I need help from you NodeJS ninjas. I am starting to learn it, after doing a good amount of LAMP stuff. I have written several systems in Apache/PHP/MySQL for a small corporate intranet (including things like a ticket system, employee scheduling, production reports, financial reports, etc).

我需要你的帮助NodeJS忍者。在做了大量的LAMP之后,我开始学习它。我已经在Apache / PHP / MySQL中为小型企业内部网编写了几个系统(包括票务系统,员工调度,生产报告,财务报告等)。

So, in LAMP world, I start the Apache and MySQL engine. Then people go to their browsers, type the server IP and browse the different systems I've written for them based on the folder in htdocs.

所以,在LAMP世界中,我启动了Apache和MySQL引擎。然后人们去他们的浏览器,键入服务器IP并根据htdocs中的文件夹浏览我为他们编写的不同系统。

I am trying to think what the equivalent would be in a set up with NodeJS, Express using the MVC model (something I am also new to). Two main questions:

我试着想一想使用NodeJS设置的等价物,Express使用MVC模型(我也是新手)。两个主要问题:

  1. Since I have several systems (employee scheduling, financial reports, etc), would each one of these have their own middleware for managing, with their middleware rules and all that? or would they all run under just a main thread? (load balancing is another thing that came up).
  2. 由于我有几个系统(员工安排,财务报告等),他们每个人都有自己的中间件用于管理,他们的中间件规则和所有这些?或者它们都只在一个主线程下运行? (负载平衡是另一件事)。
  3. What would the folder layout be? XAMPP had the htdocs folder and the folder structure was whatever I wanted.
  4. 文件夹布局是什么? XAMPP有htdocs文件夹,文件夹结构是我想要的。

From what I've seen in most tutorials, an option for a folder layout is:

从我在大多数教程中看到的,文件夹布局的选项是:

-app -- controllers -- models -- routes -- views -config -- env -node_modules -public (I imagine the systems I implement would be on here?) -server.js

-app - controllers - models - routes - views -config - env -node_modules -public(我想我实现的系统会在这里吗?) - server.js

Thank you for your help, I am still a complete noob, but I am excited to get into this.

谢谢你的帮助,我仍然是一个完整的菜鸟,但我很高兴能够参与其中。

1 个解决方案

#1


1

I come from LAMP stack word and moved to nodeJS 2 years ago. A lot changed since then.

我来自LAMP堆栈字,并于2年前移至nodeJS。从那以后发生了很多变化。

Things you need to know for nodeJS vs PHP :

您需要了解nodeJS与PHP的相关信息:

  • nodeJS runs under google's JavaScript V8 engine.
  • nodeJS在谷歌的JavaScript V8引擎下运行。
  • nodeJS is ingle-threaded. PHP is multi-thread. That means any modification to a global variable, if there's any, is seen by all the connected users.
  • nodeJS是单线程的。 PHP是多线程的。这意味着所有连接用户都可以看到对全局变量的任何修改(如果有的话)。
  • nodeJS with express alone is not MVC since MVC is a architectural pattern. You can if you want create folders to define a MVC pattern or hMVC pattern (depending on your needs). A bigger frameworks called SAILS does native MVC for you.
  • 单独表达的nodeJS不是MVC,因为MVC是一种架构模式。如果您希望创建文件夹来定义MVC模式或hMVC模式(根据您的需要),则可以。一个名为SAILS的更大框架为您提供原生MVC。
  • to start a nodeJS project, you have to cli node yourApp.js. That said, there is a better way to start a project using a script placed inside package.json managed by npm or using other npm package such as nodemon. There is no specific folder to start a project like PHP since PHP is managed by Apache and Apache is configured to have a specific folder for html docs.
  • 要启动nodeJS项目,您必须cli节点yourApp.js。也就是说,有一种更好的方法可以使用由npm管理的package.json中的脚本或使用其他npm包(如nodemon)来启动项目。没有特定的文件夹来启动像PHP这样的项目,因为PHP由Apache管理,Apache配置为具有html文档的特定文件夹。
  • Other things to add :
  • 其他要添加的内容:
  • Javascript uses EcmaScript as scripting language. The version 6 of ES was finalised in summer 2015, and all browsers still doesn't native take it in charge. Since nodejs uses google's v8 engine, it's still based on ES5.1 or experimental ES6 with --hamrony flag calling node in cli. Since node5 many ES6 features are implemented but still not all are.
  • Javascript使用EcmaScript作为脚本语言。 ES的第6版于2015年夏季完成,并且所有浏览器仍然没有本机负责。由于nodejs使用google的v8引擎,它仍然基于ES5.1或实验性ES6,在cli中使用--hamrony标志调用节点。由于node5实现了许多ES6功能,但仍然不是全部。
  • NodeJS is asynchronous, and async call are HARD to learn when you come from php word. You will need a lot of practices. I suggest you go read module pattern and revealing pattern.
  • NodeJS是异步的,当您来自php word时,异步调用很难学习。你需要很多练习。我建议你去阅读模块模式和揭示模式。

I hope I have answered you'r questions

我希望我已经回答了你的问题

更多相关文章

  1. mysql去除严格模式/插入数据库遇到重复保证唯一
  2. 非GTID模式MySQL主从同步配置
  3. Mysql研磨之InnoDB行锁模式
  4. mysql关闭严格模式
  5. mysql安装后不能重新修改目录文件夹的名字?
  6. 如何使用mysql在php文件夹中快速更改图像名称?
  7. JavaScript责任链模式
  8. Javascript字符串替换为动态创建的模式。
  9. JavaScript面向对象程序设计三——原型模式(上)

随机推荐

  1. java.lang.NoSuchMethodException:在strut
  2. jsp中如何使用javabeans,如何使用一个已经
  3. r项目:xlsx包安装失败(由于java问题)
  4. JDK1.5到1.7的进化
  5. Java区分大小写字母数字和符号
  6. JAVAWEB网站开发,一对多,多对一,主表与子表(
  7. Java项目中的classpath
  8. Tomcat 网站部署(三)
  9. 如何将树路径转换为json对象
  10. java基础中一些值得聊的话题(内存篇)