One of my favorite things with Yii is the Gii (Generator).
关于Yii(php框架)我喜爱的事情之一是Gii(生成器)Global Information Infrastructure。
With a few clicks I could simply add a few Models/Controllers/Views (or all of the above), then build/customize those.
我只需要点击几次就可以添加一些模型/控制器/视图(或者这三个一起),然后就可以构建/定制他们了。
MeanJS uses the Yeoman/Yo generator to make this happen. After installing Yeoman generator (which I believe we already installed when we installed MeanJS) via:
MeanJS 使用Yeoman/Yo生成器让这个变为可能。安装了Yeoman生成器之后(我相信在我们安装MeanJs的时候我们已经安装了) 通过:
npm install -g yo
Now to install the MeanJS generator package:
现在开始安装MeanJs生成器的包:
npm install -g generator-meanjs
(remember, often when running npm install -g you’ll need to sudo it)
(记住,当执行npm install -g 命令的时候,经常你需要用sudo提升权限来执行(linux里的命令))
Basic CRUD
基本的CRUD
For those who are not familiar with the concept, CRUD stands for – Create, Read, Update & Delete.
对于那些不熟悉这些概念的,CRUD就是 新增,读取,更新 和删除。
These are the basics one needs to present & manipulate data on a website, and a lot of web frameworks generate CRUDs as sort of a first-step.
这些是网站上基本的需求来呈现和操纵数据,并且很多web框架把生成CRUDS 作为第一步。
Let’s create our first CRUD:
让我们创建我们的第一个CRUD:
yo meanjs:crud-module firstmodule
yo meanjs:crud-module firstmodule
After selecting the supplemental folder to include in the Angular Module, and whether or not the module should be added to the menu, a bunch of files are generated.
选择补充文件夹包括进Angular模块,并且这个模块是否应该被添加到菜单里之后,一堆文件生成出来了。
Very Important: The crud-module generates both the Server side & Client files.
非常重要:这个crud模块生成包括服务端和客户端文件。
The Module Structure was explained thoroughly onBasics of MeanJS.
这个模块结构被基于的MeanJs 解释的很彻底。
The crud-module is the all encompassing, there are also sub generators:
这个crud模块是全包括,并且包含了子生成器:
- angular-module
- angular-route
- angular-controller
- angular-view
- angular-service
- angular-directive
- angular-filter
- angular-config
- angular-test
- express-model
- express-controller
- express-route
- express-test
Those names are pretty self explanatory, so I don’t see much need to go deeper there.
More information about Yeoman generator specifically used for MeanJS can be foundhere
As you can probably notice, this article came out a bit shorter than expected, this is mainly due to time constraints.
I’d like to continue and develop under MeanJS, as I see a lot of interest on the subject.
There are also a few other frameworks that I started reading about that might be a part of some future articles (some are fairly similar).
Bonus info: MeanJS was on the Changelog podcast! , very cool.